From d613c69863ce2a62571d8716151e3dc629a306e3 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Mon, 5 Feb 2024 16:08:36 +0000 Subject: [PATCH] Micro optimisations of StandardRowReader --- .../sql/results/internal/StandardRowReader.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/StandardRowReader.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/StandardRowReader.java index 6a4f9ccf80..f4addeb69f 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/StandardRowReader.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/StandardRowReader.java @@ -22,6 +22,8 @@ import org.hibernate.sql.results.spi.RowReader; import org.hibernate.sql.results.spi.RowTransformer; import org.hibernate.type.descriptor.java.JavaType; +import org.jboss.logging.Logger; + /** * @author Steve Ebersole */ @@ -34,6 +36,8 @@ public class StandardRowReader implements RowReader { private final int assemblerCount; + private static final Logger LOGGER = LoadingLogger.LOGGER; + public StandardRowReader( List> resultAssemblers, InitializersList initializers, @@ -82,14 +86,17 @@ public class StandardRowReader implements RowReader { @Override public T readRow(RowProcessingState rowProcessingState, JdbcValuesSourceProcessingOptions options) { - LoadingLogger.LOGGER.trace( "StandardRowReader#readRow" ); + LOGGER.trace( "StandardRowReader#readRow" ); coordinateInitializers( rowProcessingState ); final Object[] resultRow = new Object[ assemblerCount ]; + final boolean debugEnabled = LOGGER.isDebugEnabled(); for ( int i = 0; i < assemblerCount; i++ ) { final DomainResultAssembler assembler = resultAssemblers.get( i ); - LoadingLogger.LOGGER.debugf( "Calling top-level assembler (%s / %s) : %s", i, assemblerCount, assembler ); + if ( debugEnabled ) { + LOGGER.debugf( "Calling top-level assembler (%s / %s) : %s", i, assemblerCount, assembler ); + } resultRow[i] = assembler.assemble( rowProcessingState, options ); } @@ -99,7 +106,7 @@ public class StandardRowReader implements RowReader { } private void afterRow(RowProcessingState rowProcessingState) { - LoadingLogger.LOGGER.trace( "StandardRowReader#afterRow" ); + LOGGER.trace( "StandardRowReader#afterRow" ); initializers.finishUpRow( rowProcessingState ); }