On Tue, 28 Jan 2025 01:24:43 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 incrementally with one additional 
> commit since the last revision:
> 
>   error message

The error behavior of these two methods before PR #16050 merged on October 7, 
2023 was as follows. 

int parseInt(CharSequence s, int beginIndex, int endIndex, int radix) {
        throw NumberFormatException.forInputString("", radix);
}

long parseLong(CharSequence s, int beginIndex, int endIndex, int radix) {
        throw new NumberFormatException("");
}


This error message is not fixed, so I think it can be changed.


To be compatible with the error, I made a change to use the exception 
information of forInputString(String, int) when s is a String and beginIndex is 
0 and endIndex == s.length().

-------------

PR Comment: https://git.openjdk.org/jdk/pull/22919#issuecomment-2617468773

Reply via email to