On Sat, 1 Feb 2025 10:07:25 GMT, Shaojin Wen <s...@openjdk.org> wrote:
>> This is an optimization for decimal Integer.parseInt and Long.parseLong, >> which improves performance by about 10%. The optimization includes: >> 1. Improve performance by parsing 2 numbers at a time, which has performance >> improvements for numbers with length >= 3. >> 2. It uses charAt(0) for the first number. Assuming that the optimization >> can eliminate boundary checks, this will be more friendly to parsing numbers >> with length 1. >> 3. It removes the reliance on the Character.digit method and eliminates the >> reliance on the CharacterDataLatin1#DIGITS cache array, which avoids >> performance degradation caused by cache misses. > > Shaojin Wen has updated the pull request with a new target base due to a > merge or a rebase. The pull request now contains 29 commits: > > - Merge remote-tracking branch 'upstream/master' into > optim_parse_int_long_202501 > > # Conflicts: > # src/java.base/share/classes/jdk/internal/util/DecimalDigits.java > - multiply 10 > - copyright > - error message > - Merge remote-tracking branch 'upstream/master' into > optim_parse_int_long_202501 > > # Conflicts: > # src/java.base/share/classes/jdk/internal/util/DecimalDigits.java > - use & > - from @rgiulietti > - remove unused > - Update src/java.base/share/classes/jdk/internal/util/DecimalDigits.java > > Co-authored-by: Chen Liang <li...@openjdk.org> > - vector digit2 > - ... and 19 more: https://git.openjdk.org/jdk/compare/651ac3cc...1fb40bb9 src/java.base/share/classes/java/lang/Integer.java line 525: > 523: return parseInt0(s, radix); > 524: } > 525: int fc = value[0]; Suggestion: /* Accumulating negatively avoids surprises near MAX_VALUE */ int fc = value[0]; src/java.base/share/classes/java/lang/Long.java line 561: > 559: return parseLong0(s, radix); > 560: } > 561: int fc = value[0]; Suggestion: /* Accumulating negatively avoids surprises near MAX_VALUE */ int fc = value[0]; ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/22919#discussion_r1940916020 PR Review Comment: https://git.openjdk.org/jdk/pull/22919#discussion_r1940916196