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

dlych pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 0d3ec94  [NO ISSUE] Polish getNumCodePoint()
0d3ec94 is described below

commit 0d3ec94b236f09e498d8ab91bce5cc2f5f5b1d86
Author: Rui Guo <[email protected]>
AuthorDate: Sun Jul 26 11:20:34 2020 -0700

    [NO ISSUE] Polish getNumCodePoint()
    
    Polish to reuse existing codes to make things more clear
    
    Change-Id: Ibe5a60a54590f4f72cac9e5ccda973ac30b339c5
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/7343
    Integration-Tests: Jenkins <[email protected]>
    Tested-by: Dmitry Lychagin <[email protected]>
    Reviewed-by: Dmitry Lychagin <[email protected]>
---
 .../apache/hyracks/util/string/UTF8StringUtil.java  | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git 
a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/string/UTF8StringUtil.java
 
b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/string/UTF8StringUtil.java
index e1a7cac..53271e4 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/string/UTF8StringUtil.java
+++ 
b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/string/UTF8StringUtil.java
@@ -205,25 +205,8 @@ public class UTF8StringUtil {
         int end = pos + len;
         int codePointCount = 0;
         while (pos < end) {
-            char ch = charAt(b, pos);
-
-            if (Character.isHighSurrogate(ch)) {
-                pos += charSize(b, pos);
-                ch = charAt(b, pos);
-                if (Character.isLowSurrogate(ch)) {
-                    codePointCount++;
-                } else {
-                    throw new IllegalArgumentException(
-                            "Decoding error: get a high surrogate without a 
following low surrogate when counting number of code points");
-                }
-            } else if (Character.isLowSurrogate(ch)) {
-                throw new IllegalArgumentException(
-                        "Decoding error: get a low surrogate without a leading 
high surrogate when counting number of code points");
-            } else {
-                // A single-Java-Char code point (not a surrogate pair)
-                codePointCount++;
-            }
-            pos += charSize(b, pos);
+            codePointCount++;
+            pos += codePointSize(b, pos);
         }
 
         return codePointCount;

Reply via email to