You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by am...@apache.org on 2023/11/13 03:10:00 UTC

(iceberg) branch main updated: API: Optimize equals in CharSequenceWrapper (#9035)

This is an automated email from the ASF dual-hosted git repository.

amoghj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg.git


The following commit(s) were added to refs/heads/main by this push:
     new fd4231f5e2 API: Optimize equals in CharSequenceWrapper (#9035)
fd4231f5e2 is described below

commit fd4231f5e27c6a98bbf4ff38850e1700b7584c0a
Author: Anton Okolnychyi <ao...@apple.com>
AuthorDate: Sun Nov 12 19:09:55 2023 -0800

    API: Optimize equals in CharSequenceWrapper (#9035)
---
 .../main/java/org/apache/iceberg/util/CharSequenceWrapper.java   | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/api/src/main/java/org/apache/iceberg/util/CharSequenceWrapper.java b/api/src/main/java/org/apache/iceberg/util/CharSequenceWrapper.java
index 28c4449701..e022120602 100644
--- a/api/src/main/java/org/apache/iceberg/util/CharSequenceWrapper.java
+++ b/api/src/main/java/org/apache/iceberg/util/CharSequenceWrapper.java
@@ -52,6 +52,15 @@ public class CharSequenceWrapper implements CharSequence, Serializable {
     }
 
     CharSequenceWrapper that = (CharSequenceWrapper) other;
+
+    if (wrapped instanceof String && that.wrapped instanceof String) {
+      return wrapped.equals(that.wrapped);
+    }
+
+    if (length() != that.length()) {
+      return false;
+    }
+
     return Comparators.charSequences().compare(wrapped, that.wrapped) == 0;
   }