mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8225061: Performance regression in Regex
Co-authored-by: Naoto Sato <naoto.sato@oracle.com> Reviewed-by: naoto, alanb
This commit is contained in:
parent
d2ad9dabdf
commit
1813ce706a
5 changed files with 170 additions and 30 deletions
|
@ -3973,7 +3973,16 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
|||
if (i < matcher.to) {
|
||||
int ch0 = Character.codePointAt(seq, i);
|
||||
int n = Character.charCount(ch0);
|
||||
int j = Grapheme.nextBoundary(seq, i, matcher.to);
|
||||
int j = i + n;
|
||||
// Fast check if it's necessary to call Normalizer;
|
||||
// testing Grapheme.isBoundary is enough for this case
|
||||
while (j < matcher.to) {
|
||||
int ch1 = Character.codePointAt(seq, j);
|
||||
if (Grapheme.isBoundary(ch0, ch1))
|
||||
break;
|
||||
ch0 = ch1;
|
||||
j += Character.charCount(ch1);
|
||||
}
|
||||
if (i + n == j) { // single, assume nfc cp
|
||||
if (predicate.is(ch0))
|
||||
return next.match(matcher, j, seq);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue