From f4e58d342de63369c5797e8580d5c3f08000b0e7 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Thu, 19 Nov 2015 10:04:17 +1100 Subject: [PATCH] HHH-10301 Don't allocate a new List if it is not required --- .../java/org/hibernate/engine/query/spi/HQLQueryPlan.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/query/spi/HQLQueryPlan.java b/hibernate-core/src/main/java/org/hibernate/engine/query/spi/HQLQueryPlan.java index c84fa8f6e9..1d2612fa19 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/query/spi/HQLQueryPlan.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/query/spi/HQLQueryPlan.java @@ -211,6 +211,10 @@ public class HQLQueryPlan implements Serializable { queryParametersToUse = queryParameters; } + //fast path to avoid unnecessary allocation and copying + if ( translators.length == 1 ) { + return translators[0].list( session, queryParametersToUse ); + } final int guessedResultSize = guessResultSize( rowSelection ); final List combinedResults = new ArrayList( guessedResultSize ); final IdentitySet distinction;