Skip to content

Conversation

@triceo
Copy link
Collaborator

@triceo triceo commented Jan 6, 2026

  • Change hashCode() implementation in types which are commonly used in hashing (such as pairs and composite keys) due to the default methods for records doing far too much work.
  • The pattern used in these methods now is the same as you'd find in Objects.hashCode(...) and Objects.equals(...), with the assumption that the JDK project optimized those. We avoid actually calling these JDK methods due to https://bugs.openjdk.org/browse/JDK-8015417.
  • Also brought value ranges in line with this convention.

Copilot AI review requested due to automatic review settings January 6, 2026 06:08
@triceo triceo requested a review from zepfred as a code owner January 6, 2026 06:08
@triceo triceo self-assigned this Jan 6, 2026
@triceo triceo added this to the v1.30.0 milestone Jan 6, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes hashing performance across commonly used data structures by replacing JDK utility methods with custom implementations that avoid known performance issues. The changes target types frequently used as hash keys (Pair, Triple, Quadruple, composite keys) and value ranges.

Key changes:

  • Replace Objects.hash() and Objects.hashCode() with direct hashCode calculations to avoid array allocation and performance bugs
  • Standardize initial hash seed value from 7 to 1 across all implementations
  • Leverage @NullMarked annotations to remove redundant null checks

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 28 comments.

Show a summary per file
File Description
Pair.java, Triple.java, Quadruple.java Optimized equals/hashCode for tuple classes with manual null-safe implementations
BiCompositeKey.java Updated composite key hashing to avoid Objects utility methods
MegaCompositeKey.java Changed to use Arrays.deepEquals/deepHashCode for proper array comparison
TemporalValueRange.java Removed null checks, updated equals/hashCode, simplified annotations
IntValueRange.java, LongValueRange.java Updated primitive wrapper range classes with optimized hashing
BigIntegerValueRange.java, BigDecimalValueRange.java Improved hashing for big number ranges
BooleanValueRange.java Simplified contains() logic and removed unnecessary Boolean.valueOf()
SetValueRange.java, ListValueRange.java Updated collection-based ranges with optimized equals/hashCode
CompositeCountableValueRange.java, NullAllowingCountableValueRange.java Improved composite range hashing
DoubleValueRange.java Simplified hashCode calculation (though inconsistent with other changes)
EmptyValueRange.java Changed singleton hashCode from 7 to 0
TestdataObjectEquals.java Simplified test class hashCode
TemporalValueRangeTest.java Removed null validation tests (covered by @NullMarked)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 6, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
37.9% Coverage on New Code (required ≥ 70%)
5.6% Duplication on New Code (required ≤ 5%)

See analysis details on SonarQube Cloud

Co-authored-by: Frederico Gonçalves <[email protected]>
…nge/buildin/collection/SetValueRange.java

Co-authored-by: Frederico Gonçalves <[email protected]>
…nge/buildin/composite/NullAllowingCountableValueRange.java

Co-authored-by: Frederico Gonçalves <[email protected]>
…nge/buildin/composite/CompositeCountableValueRange.java

Co-authored-by: Frederico Gonçalves <[email protected]>
…nge/buildin/collection/ListValueRange.java

Co-authored-by: Frederico Gonçalves <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@triceo triceo merged commit 7ec4e34 into TimefoldAI:main Jan 6, 2026
39 of 76 checks passed
@triceo triceo deleted the hashx branch January 6, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants