Skip to content

Commit 53bb5c8

Browse files
tatu-at-datastaxabsurdfarce
authored andcommitted
CASSJAVA-68 Improve DefaultCodecRegisry.CacheKey#hashCode() to eliminate Object[] allocation (found via profiler)
patch by Tatu Saloranta; reviewed by Dmitry Konstantinov and Bret McGuire for CASSJAVA-68
1 parent eb54934 commit 53bb5c8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

core/src/main/java/com/datastax/oss/driver/internal/core/type/codec/registry/DefaultCodecRegistry.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ public boolean equals(Object other) {
159159

160160
@Override
161161
public int hashCode() {
162-
return Objects.hash(cqlType, javaType, isJavaCovariant);
162+
// NOTE: inlined Objects.hash for performance reasons (avoid Object[] allocation
163+
// seen in profiler allocation traces)
164+
return ((31 + Objects.hashCode(cqlType)) * 31 + Objects.hashCode(javaType)) * 31
165+
+ Boolean.hashCode(isJavaCovariant);
163166
}
164167
}
165168
}

0 commit comments

Comments
 (0)