RFR: 8347009: Speed ​​up parseInt and parseLong [v4]

Shaojin Wen swen at openjdk.org
Sun Jan 5 07:10:09 UTC 2025


On Sun, 5 Jan 2025 02:57:37 GMT, j3graham <duke at openjdk.org> wrote:

>> Shaojin Wen has updated the pull request incrementally with 11 additional commits since the last revision:
>> 
>>  - emptyInput -> nullInput
>>  - use CharacterDataLatin1.instance::isDigit
>>  - add comments
>>  - reduce codeSize
>>  - bug fix for bound check
>>  - reduce codeSize
>>  - remove unused code
>>  - code format
>>  - bug fix
>>  - bug fix
>>  - ... and 1 more: https://git.openjdk.org/jdk/compare/9ea08455...fd51c1ce
>
> src/java.base/share/classes/java/lang/Integer.java line 576:
> 
>> 574:             throw NumberFormatException.forInputString(s);
>> 575:         }
>> 576:         return parseInt(s, 0, len, radix);
> 
> I  think this call will result in different exception messages in some cases. Consolidating the exception messages between the String and the CharSequence parsing methods would likely allow for even more code simplification,  but currently it appears there was effort to preserve the exact message text in exceptions.

If we want to keep the original error message completely, we need to keep the original implementation, which will lead to code duplication.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22919#discussion_r1903193687


More information about the core-libs-dev mailing list