Skip to content

Commit 5f1200c

Browse files
committed
Reimplement StringUtils.toCodePoints(CharSequence) to use
java.lang.CharSequence.codePoints()
1 parent 4bca9b4 commit 5f1200c

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

Diff for: src/changes/changes.xml

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ The <action> type attribute can be add,update,fix,remove.
8484
<action issue="LANG-1764" type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate NumericEntityUnescaper.OPTION in favor of Apache Commons Text.</action>
8585
<action type="fix" dev="ggregory" due-to="Gary Gregory">Several hash collisions in Fraction class.</action>
8686
<action issue="LANG-1768" type="fix" dev="ggregory" due-to="Wang Hailong, Gary Gregory">MutableLong and friends should provide better parsing exceptions Javadocs.</action>
87+
<action type="fix" dev="ggregory" due-to="Gary Gregory">Reimplement StringUtils.toCodePoints(CharSequence) to use java.lang.CharSequence.codePoints().</action>
8788
<!-- ADD -->
8889
<action type="add" dev="ggregory" due-to="Gary Gregory">Add Strings and refactor StringUtils.</action>
8990
<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 for: src/main/java/org/apache/commons/lang3/StringUtils.java

+1-9
Original file line numberDiff line numberDiff line change
@@ -8693,15 +8693,7 @@ public static int[] toCodePoints(final CharSequence cs) {
86938693
if (cs.length() == 0) {
86948694
return ArrayUtils.EMPTY_INT_ARRAY;
86958695
}
8696-
8697-
final String s = cs.toString();
8698-
final int[] result = new int[s.codePointCount(0, s.length())];
8699-
int index = 0;
8700-
for (int i = 0; i < result.length; i++) {
8701-
result[i] = s.codePointAt(index);
8702-
index += Character.charCount(result[i]);
8703-
}
8704-
return result;
8696+
return cs.toString().codePoints().toArray();
87058697
}
87068698

87078699
/**

0 commit comments

Comments
 (0)