Skip to content

Commit cdc428c

Browse files
committed
[optimisation] Optimise for object identity equality
1 parent d11da90 commit cdc428c

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

  • exist-core/src/main/java/org/exist/dom/persistent
  • extensions/indexes/lucene/src/main/java/org/exist/indexing/lucene

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
@@ -391,6 +391,10 @@ public static boolean matchListEquals(final Match m1, final Match m2) {
391391

392392
@Override
393393
public boolean equals(final Object other) {
394+
if (other == this) {
395+
return true;
396+
}
397+
394398
if (other instanceof Match) {
395399
final Match om = (Match) other;
396400
return om.matchTerm != null
@@ -401,7 +405,6 @@ public boolean equals(final Object other) {
401405
}
402406
}
403407

404-
405408
/**
406409
* Used to sort matches. Terms are compared by their string
407410
* 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
@@ -93,6 +93,10 @@ public Facets getFacets() {
9393
// DW: missing hashCode() ?
9494
@Override
9595
public boolean equals(final Object other) {
96+
if (other == this) {
97+
return true;
98+
}
99+
96100
if (other instanceof LuceneMatch) {
97101
final LuceneMatch lm = (LuceneMatch) other;
98102
return getNodeId().equals(lm.getNodeId())

0 commit comments

Comments
 (0)