garydgregory commented on PR #1327:
URL: https://github.com/apache/commons-lang/pull/1327#issuecomment-2553968124
Another issue here is that for every single step in the `for` loop, the PR
does a `sequential` search in a collection. Is it worth doing a binary search
instead? Like this:
```java
public static int indexOfAnyBut(final CharSequence seq, final
CharSequence searchChars) {
if (isEmpty(seq) || isEmpty(searchChars)) {
return INDEX_NOT_FOUND;
}
int[] codePoints =
ArraySorter.sort(searchChars.codePoints().toArray());
// advance character index from one interpreted codepoint to the next
for (int curSeqCharIdx = 0; curSeqCharIdx < seq.length();) {
final int curSeqCodePoint = Character.codePointAt(seq,
curSeqCharIdx);
if (Arrays.binarySearch(codePoints, curSeqCodePoint) < 0) {
return curSeqCharIdx;
}
curSeqCharIdx += Character.charCount(curSeqCodePoint); // skip
indices to paired low-surrogates
}
return INDEX_NOT_FOUND;
}
```
--
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]