[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 <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Dmitry Lychagin <dmitry.lychagin@couchbase.com>
Reviewed-by: Dmitry Lychagin <dmitry.lychagin@couchbase.com>
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 @@
         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;