Skip to content

Commit

Permalink
HV-1444 Introduce a couple of micro optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Mar 6, 2018
1 parent 5e7d3d4 commit b73fe21
Showing 1 changed file with 11 additions and 8 deletions.
Expand Up @@ -247,12 +247,12 @@ private Set<ValueExtractorDescriptor> getPotentiallyRuntimeTypeCompliantAndConta

private ValueExtractorDescriptor getUniqueValueExtractorOrThrowException(Class<?> runtimeType,
Set<ValueExtractorDescriptor> maximallySpecificContainerElementCompliantValueExtractors) {
if ( maximallySpecificContainerElementCompliantValueExtractors.isEmpty() ) {
return null;
}
else if ( maximallySpecificContainerElementCompliantValueExtractors.size() == 1 ) {
if ( maximallySpecificContainerElementCompliantValueExtractors.size() == 1 ) {
return maximallySpecificContainerElementCompliantValueExtractors.iterator().next();
}
else if ( maximallySpecificContainerElementCompliantValueExtractors.isEmpty() ) {
return null;
}
else {
throw LOG.getUnableToGetMostSpecificValueExtractorDueToSeveralMaximallySpecificValueExtractorsDeclaredException( runtimeType,
ValueExtractorHelper.toValueExtractorClasses( maximallySpecificContainerElementCompliantValueExtractors )
Expand Down Expand Up @@ -400,9 +400,11 @@ private TypeVariable<?> bind(TypeVariable<?> typeParameter, Map<TypeVariable<?>,

private static class ValueExtractorCacheKey {

private final Class<?> type;
private final TypeVariable<?> typeParameter;
private final int hashCode;
// These properties are not final on purpose, it's faster when they are not

private Class<?> type;
private TypeVariable<?> typeParameter;
private int hashCode;

ValueExtractorCacheKey(Class<?> type, TypeVariable<?> typeParameter) {
this.type = type;
Expand All @@ -415,9 +417,10 @@ public boolean equals(Object o) {
if ( this == o ) {
return true;
}
if ( o == null || this.getClass() != o.getClass() ) {
if ( o == null ) {
return false;
}
// We don't check the class as an optimization, the keys of the map are ValueExtractorCacheKey anyway
ValueExtractorCacheKey that = (ValueExtractorCacheKey) o;
return Objects.equals( this.type, that.type ) &&
Objects.equals( this.typeParameter, that.typeParameter );
Expand Down

0 comments on commit b73fe21

Please sign in to comment.