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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git

commit 5f1200c35e1f115b20cf81e0625bc7ea3d34a03d
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Tue Apr 15 15:01:17 2025 -0400

    Reimplement StringUtils.toCodePoints(CharSequence) to use
    java.lang.CharSequence.codePoints()
---
 src/changes/changes.xml                                 |  1 +
 src/main/java/org/apache/commons/lang3/StringUtils.java | 10 +---------
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 114669cf9..8cd9319fe 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -84,6 +84,7 @@ The <action> type attribute can be add,update,fix,remove.
     <action issue="LANG-1764" type="fix" dev="ggregory" due-to="Gary 
Gregory">Deprecate NumericEntityUnescaper.OPTION in favor of Apache Commons 
Text.</action>
     <action                   type="fix" dev="ggregory" due-to="Gary 
Gregory">Several hash collisions in Fraction class.</action>
     <action issue="LANG-1768" type="fix" dev="ggregory" due-to="Wang Hailong, 
Gary Gregory">MutableLong and friends should provide better parsing exceptions 
Javadocs.</action>
+    <action                   type="fix" dev="ggregory" due-to="Gary 
Gregory">Reimplement StringUtils.toCodePoints(CharSequence) to use 
java.lang.CharSequence.codePoints().</action>
     <!-- ADD -->
     <action                   type="add" dev="ggregory" due-to="Gary 
Gregory">Add Strings and refactor StringUtils.</action>
     <action issue="LANG-1747" type="add" dev="ggregory" due-to="Oliver B. 
Fischer, Gary Gregory">Add StopWatch.run([Failable]Runnable) and 
get([Failable]Supplier).</action>
diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java 
b/src/main/java/org/apache/commons/lang3/StringUtils.java
index 2bf8d64bd..207fb025b 100644
--- a/src/main/java/org/apache/commons/lang3/StringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java
@@ -8693,15 +8693,7 @@ public static int[] toCodePoints(final CharSequence cs) {
         if (cs.length() == 0) {
             return ArrayUtils.EMPTY_INT_ARRAY;
         }
-
-        final String s = cs.toString();
-        final int[] result = new int[s.codePointCount(0, s.length())];
-        int index = 0;
-        for (int i = 0; i < result.length; i++) {
-            result[i] = s.codePointAt(index);
-            index += Character.charCount(result[i]);
-        }
-        return result;
+        return cs.toString().codePoints().toArray();
     }
 
     /**

Reply via email to