rmuir commented on code in PR #16414:
URL: https://github.com/apache/lucene/pull/16414#discussion_r3788309265
##########
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) {
Review Comment:
Although the class is package private, these kinds of checks could easily
break if a new subclass was introduced.
For safety, could we mark IntSet as a sealed class? Both implementations are
final, and then its possible to do an exhaustive pattern-match that's checked
at compile-time here. I think. @uschindler would know for sure.
--
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]