garydgregory commented on code in PR #1327:
URL: https://github.com/apache/commons-lang/pull/1327#discussion_r1873244306
##########
src/main/java/org/apache/commons/lang3/StringUtils.java:
##########
@@ -2888,17 +2876,20 @@ public static int indexOfAnyBut(final CharSequence seq,
final CharSequence searc
if (isEmpty(seq) || isEmpty(searchChars)) {
return INDEX_NOT_FOUND;
}
- final int strLen = seq.length();
- for (int i = 0; i < strLen; i++) {
- final char ch = seq.charAt(i);
- final boolean chFound = CharSequenceUtils.indexOf(searchChars, ch,
0) >= 0;
- if (i + 1 < strLen && Character.isHighSurrogate(ch)) {
- final char ch2 = seq.charAt(i + 1);
- if (chFound && CharSequenceUtils.indexOf(searchChars, ch2, 0)
< 0) {
- return i;
- }
- } else if (!chFound) {
- return i;
+ final Set<Integer> seqSetCodePoints =
seq.codePoints().boxed().collect(Collectors.toSet()); // JDK >=10:
Collectors::toUnmodifiableSet
+ final Set<Integer> searchSetCodePoints =
searchChars.codePoints().boxed()
+ .collect(Collectors.toSet()); // JDK >=10:
Collectors::toUnmodifiableSet
+ final Set<Integer> complSetCodePoints =
seqSetCodePoints.stream().filter(((Predicate<Integer>)
searchSetCodePoints::contains).negate()) // JDK >=11:
Predicate.not(searchSetCodePoints::contains)
+ .collect(Collectors.toSet()); // JDK >=10:
Collectors::toUnmodifiableSet
Review Comment:
We can't jump off of Java 8 yet. I think we'd leave too many people behind.
At least based on current surveys.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]