RFR: 8370013: Refactor Double.toHexString to eliminate regex and StringBuilder [v9]
Joe Darcy
darcy at openjdk.org
Tue Oct 21 03:29:03 UTC 2025
On Tue, 21 Oct 2025 01:28:50 GMT, Shaojin Wen <swen at openjdk.org> wrote:
>> This PR refactors the Double.toHexString method to improve its performance by eliminating the use of StringBuilder and regex operations. The new implementation uses a direct byte array approach to construct the hex string representation, which avoids the overhead of StringBuilder operations and regex pattern matching.
>>
>> Existing tests in `java/lang/Double/ToHexString.java`.
>
> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
>
> fix test comment
test/jdk/java/lang/Double/ToHexString.java line 182:
> 180: {"0x1.1p1", "4001000000000000"}, // Maximum trailing zeros (all zeros after '1')
> 181: {"0x1.0p1", "4000000000000000"}, // Maximum trailing zeros (all zeros after '0')
> 182: {"0x1.01p1", "4000100000000000"}, // 1 trailing zero removed
Shouldn't the number of trailing zeros be counting down at this point?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27811#discussion_r2446630172
More information about the core-libs-dev
mailing list