mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8262994: Refactor String.split to help method inlining
Reviewed-by: plevart
This commit is contained in:
parent
2d7690b2e5
commit
622b6594d1
1 changed files with 42 additions and 33 deletions
|
@ -3129,6 +3129,17 @@ public final class String
|
|||
(ch < Character.MIN_HIGH_SURROGATE ||
|
||||
ch > Character.MAX_LOW_SURROGATE))
|
||||
{
|
||||
// All the checks above can potentially be constant folded by
|
||||
// a JIT/AOT compiler when the regex is a constant string.
|
||||
// That requires method inlining of the checks, which is only
|
||||
// possible when the actual split logic is in a separate method
|
||||
// because the large split loop can usually not be inlined.
|
||||
return split(ch, limit);
|
||||
}
|
||||
return Pattern.compile(regex).split(this, limit);
|
||||
}
|
||||
|
||||
private String[] split(char ch, int limit) {
|
||||
int off = 0;
|
||||
int next = 0;
|
||||
boolean limited = limit > 0;
|
||||
|
@ -3163,8 +3174,6 @@ public final class String
|
|||
String[] result = new String[resultSize];
|
||||
return list.subList(0, resultSize).toArray(result);
|
||||
}
|
||||
return Pattern.compile(regex).split(this, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits this string around matches of the given <a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue