epotyom commented on code in PR #16414:
URL: https://github.com/apache/lucene/pull/16414#discussion_r3776985817
##########
lucene/core/src/java/org/apache/lucene/util/automaton/StateSet.java:
##########
Review Comment:
Can we remove this line now that equals() can work without getArray()? Can
make other use cases faster, unless they depend on the array being sorted
##########
lucene/core/src/java/org/apache/lucene/util/automaton/StateSet.java:
##########
@@ -121,4 +121,36 @@ long longHashCode() {
hashUpdated = true;
return hashCode;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof IntSet that)) {
+ return false;
+ }
+ if (size() != that.size()) {
+ return false;
+ }
+ if (longHashCode() != that.longHashCode()) {
+ return false;
+ }
+ if (that instanceof FrozenIntSet frozen) {
+ int[] vals = frozen.values;
+ for (int val : vals) {
+ if (!inner.containsKey(val)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ if (that instanceof StateSet otherStateSet) {
+ for (IntCursor key : otherStateSet.inner.keys()) {
+ if (!inner.containsKey(key.value)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return Arrays.equals(getArray(), 0, size(), that.getArray(), 0,
that.size());
Review Comment:
I think we don't need this fall back once @rmuir 's suggestion above is
implemented
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]