Commit 98e25684 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

[regexp] Better optimize the loop inside GetCaseIndependentLetters

Move the "if (!((start >= 128) && (character < 128))) {" check
 outside while (start <= end) loop.

Bug: v8:9731
Change-Id: I1f7e2fea189f0eba0b52100ac8d4063e7d79a306
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1832911Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64194}
parent 0243ada1
...@@ -739,17 +739,18 @@ static int GetCaseIndependentLetters(Isolate* isolate, uc16 character, ...@@ -739,17 +739,18 @@ static int GetCaseIndependentLetters(Isolate* isolate, uc16 character,
UChar32 start = set.getRangeStart(i); UChar32 start = set.getRangeStart(i);
UChar32 end = set.getRangeEnd(i); UChar32 end = set.getRangeEnd(i);
CHECK(end - start + items <= letter_length); CHECK(end - start + items <= letter_length);
while (start <= end) {
if (one_byte_subject && start > String::kMaxOneByteCharCode) break;
// Only add to the output if character is not in ASCII range // Only add to the output if character is not in ASCII range
// or the case equivalent character is in ASCII range. // or the case equivalent character is in ASCII range.
// #sec-runtime-semantics-canonicalize-ch // #sec-runtime-semantics-canonicalize-ch
// 3.g If the numeric value of ch ≥ 128 and the numeric value of cu < 128, // 3.g If the numeric value of ch ≥ 128 and the numeric value of cu < 128,
// return ch. // return ch.
if (!((start >= 128) && (character < 128))) { if (!((start >= 128) && (character < 128))) {
letters[items++] = (unibrow::uchar)(start); // No range have start and end span across code point 128.
DCHECK((start >= 128) == (end >= 128));
for (UChar32 cu = start; cu <= end; cu++) {
if (one_byte_subject && cu > String::kMaxOneByteCharCode) break;
letters[items++] = (unibrow::uchar)(cu);
} }
start++;
} }
} }
return items; return items;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment