dweiss commented on code in PR #16355:
URL: https://github.com/apache/lucene/pull/16355#discussion_r3529324164
##########
lucene/core/src/java/org/apache/lucene/analysis/CharacterUtils.java:
##########
@@ -53,10 +53,19 @@ public static CharacterBuffer newCharacterBuffer(final int
bufferSize) {
public static void toLowerCase(final char[] buffer, final int offset, final
int limit) {
assert buffer.length >= limit;
assert 0 <= offset && offset <= buffer.length;
- for (int i = offset; i < limit; ) {
- i +=
- Character.toChars(
- Character.toLowerCase(Character.codePointAt(buffer, i, limit)),
buffer, i);
+ for (int i = offset; i < limit; i++) {
+ char c = buffer[i];
+ if (c > 127) { // non-ASCII: switch to full Unicode path from here onward
+ for (int j = i; j < limit; ) {
+ j +=
+ Character.toChars(
+ Character.toLowerCase(Character.codePointAt(buffer, j,
limit)), buffer, j);
+ }
+ return;
+ }
+ if (c >= 'A' && c <= 'Z') {
+ buffer[i] = (char) (c | 32); // set bit 5 to lowercase ASCII
Review Comment:
Well, it can't overflow - it's inside the if statement so you know exactly
the minimum and maximum value it can take. And the compiler would fold the
constant 'a' - 'A'. But fine.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]