Skip to content

Commit 7e4be89

Browse files
committed
[optimisation] Optimise for object identity equality
1 parent d2c86b9 commit 7e4be89

File tree

2 files changed

+8
-1
lines changed
  • exist-core/src/main/java/org/exist/dom/persistent
  • extensions/indexes/lucene/src/main/java/org/exist/indexing/lucene

2 files changed

+8
-1
lines changed

exist-core/src/main/java/org/exist/dom/persistent/Match.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,10 @@ public static boolean matchListEquals(final Match m1, final Match m2) {
415415

416416
@Override
417417
public boolean equals(final Object other) {
418+
if (other == this) {
419+
return true;
420+
}
421+
418422
if (other instanceof Match) {
419423
final Match om = (Match) other;
420424
return om.matchTerm != null
@@ -425,7 +429,6 @@ public boolean equals(final Object other) {
425429
}
426430
}
427431

428-
429432
/**
430433
* Used to sort matches. Terms are compared by their string
431434
* length to have the longest string first.

extensions/indexes/lucene/src/main/java/org/exist/indexing/lucene/LuceneMatch.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ public Facets getFacets() {
117117
// DW: missing hashCode() ?
118118
@Override
119119
public boolean equals(final Object other) {
120+
if (other == this) {
121+
return true;
122+
}
123+
120124
if (other instanceof LuceneMatch) {
121125
final LuceneMatch lm = (LuceneMatch) other;
122126
return getNodeId().equals(lm.getNodeId())

0 commit comments

Comments
 (0)