mayya-sharipova commented on code in PR #16261:
URL: https://github.com/apache/lucene/pull/16261#discussion_r3432585594


##########
lucene/core/src/java/org/apache/lucene/analysis/CharArraySet.java:
##########
@@ -166,6 +167,31 @@ public Iterator<Object> iterator() {
     return map.originalKeySet().iterator();
   }
 
+  /** Returns {@code true} if this set matches entries case-insensitively. */
+  public boolean isIgnoreCase() {
+    return map.isIgnoreCase();
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (o == this) return true;
+    if (!(o instanceof CharArraySet other)) return false;
+    if (isIgnoreCase() != other.isIgnoreCase()) return false;
+    if (size() != other.size()) return false;
+    return containsAll(other);
+  }
+
+  @Override
+  public int hashCode() {
+    int h = Boolean.hashCode(isIgnoreCase());
+    for (char[] key : map.keys) {
+      if (key != null) {
+        h += Arrays.hashCode(key);
+      }
+    }

Review Comment:
   Technically true but the tradeoff is intentional. The previous commit 
(9a959f306ea) deliberately switched to iterating map.keys directly to avoid the 
char[] clone that MapEntry.getKey() would cause when using the set iterator. 
Since
     CharArrayMap doesn't support removal, the table is never sparse — load 
factor keeps capacity within ~2× size.



-- 
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]

Reply via email to