HHH-16091 Make AbstractStandardBasicType#getReturnedClass return a constant

This commit is contained in:
Sanne Grinovero 2023-01-24 17:32:49 +00:00 committed by Sanne Grinovero
parent 12abcc4c60
commit b77bbf0650
1 changed files with 5 additions and 1 deletions

View File

@ -49,6 +49,7 @@ public abstract class AbstractStandardBasicType<T>
private final ValueExtractor<T> jdbcValueExtractor;
private final JdbcLiteralFormatter<T> jdbcLiteralFormatter;
private final AbstractClassJavaType<T> javaTypeAsAbstractClassJavaType;
private final Class javaTypeClass;
public AbstractStandardBasicType(JdbcType jdbcType, JavaType<T> javaType) {
this.jdbcType = jdbcType;
@ -58,6 +59,9 @@ public abstract class AbstractStandardBasicType<T>
this.jdbcValueBinder = jdbcType.getBinder( javaType );
this.jdbcValueExtractor = jdbcType.getExtractor( javaType );
this.jdbcLiteralFormatter = jdbcType.getJdbcLiteralFormatter( javaType );
//A very simple dispatch optimisation, make this a constant:
this.javaTypeClass = javaType.getJavaTypeClass();
//This is a dispatch optimisation to avoid megamorphic invocations on the most common type:
if ( javaType instanceof AbstractClassJavaType ) {
this.javaTypeAsAbstractClassJavaType = (AbstractClassJavaType) javaType;
@ -123,7 +127,7 @@ public abstract class AbstractStandardBasicType<T>
@Override
public final Class getReturnedClass() {
return javaType.getJavaTypeClass();
return javaTypeClass;
}
@Override