You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ab...@apache.org on 2025/04/29 21:06:23 UTC
(cassandra-java-driver) branch 4.x updated: Improve DefaultCodecRegisry.CacheKey#hashCode() to eliminate Object[] allocation (found via profiler)
This is an automated email from the ASF dual-hosted git repository.
absurdfarce pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/cassandra-java-driver.git
The following commit(s) were added to refs/heads/4.x by this push:
new e3930c1c7 Improve DefaultCodecRegisry.CacheKey#hashCode() to eliminate Object[] allocation (found via profiler)
e3930c1c7 is described below
commit e3930c1c79c671dfa526c7c62a7928aa3d3fc226
Author: Tatu Saloranta <ta...@datastax.com>
AuthorDate: Fri Nov 15 18:41:50 2024 -0800
Improve DefaultCodecRegisry.CacheKey#hashCode() to eliminate Object[] allocation (found via profiler)
---
.../internal/core/type/codec/registry/DefaultCodecRegistry.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/core/src/main/java/com/datastax/oss/driver/internal/core/type/codec/registry/DefaultCodecRegistry.java b/core/src/main/java/com/datastax/oss/driver/internal/core/type/codec/registry/DefaultCodecRegistry.java
index cfd053ea5..4334f22b6 100644
--- a/core/src/main/java/com/datastax/oss/driver/internal/core/type/codec/registry/DefaultCodecRegistry.java
+++ b/core/src/main/java/com/datastax/oss/driver/internal/core/type/codec/registry/DefaultCodecRegistry.java
@@ -159,7 +159,10 @@ public class DefaultCodecRegistry extends CachingCodecRegistry {
@Override
public int hashCode() {
- return Objects.hash(cqlType, javaType, isJavaCovariant);
+ // NOTE: inlined Objects.hash for performance reasons (avoid Object[] allocation
+ // seen in profiler allocation traces)
+ return ((31 + Objects.hashCode(cqlType)) * 31 + Objects.hashCode(javaType)) * 31
+ + Boolean.hashCode(isJavaCovariant);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org