On Mon, 9 Jan 2023 20:04:34 GMT, Christian Wimmer <cwim...@openjdk.org> wrote:
>> The method `String.split` contains a fast-path when the regular expression >> parameter is not really a regular expression, but just a single split >> character. >> This fast path vs. slow path check can be constant folded when the regular >> expression parameter is a literal constant - a quite frequent pattern (for >> example, all JDK usages of `String.split` have a constant expression >> parameter). But method inlining in JIT and AOT compilers can usually not >> inline `String.split` because the method body is too large. Factoring out >> the actual fast-path splitting logic into a separate method solves this >> problem: the JIT or AOT compiler can inline `String.split`, constant-fold >> the fast/slow path check, and then only the invoke of either the fast path >> or the slow path remains. > > Christian Wimmer has updated the pull request incrementally with one > additional commit since the last revision: > > Add comment about method inlining Looks good. src/java.base/share/classes/java/lang/String.java line 3130: > 3128: ((ch-'A')|('Z'-ch)) < 0)) && > 3129: (ch < Character.MIN_HIGH_SURROGATE || > 3130: ch > Character.MAX_LOW_SURROGATE)) Not your change, but I'd replace them with `MIN_SURROGATE` and `MAX_SURROGATE` respectively, for readability, taking the opportunity. ------------- PR: https://git.openjdk.org/jdk/pull/11791