Skip to content

Commit

Permalink
Fix hashcode/equals
Browse files Browse the repository at this point in the history
  • Loading branch information
franz1981 committed Dec 12, 2023
1 parent ccb466a commit 6d2abc0
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,15 @@ private static int hash(String value, int length) {
}

private boolean doEquals(String s1, String s2, int length) {
if (length == s1.length() && length == s2.length()) {
var s1Len = s1.length();
int s2Len;
if (s1Len != length || (s2Len = s2.length()) < length) {
return false;
}
if (s2Len == length) {
return s1.equals(s2);
}
// s1len == length && s2Len > length
return s1.regionMatches(0, s2, 0, length);
}

Expand Down

0 comments on commit 6d2abc0

Please sign in to comment.