RFR: 8377427: Reduce substring allocations in Color.web(String, double) [v6]

Michael Strauß mstrauss at openjdk.org
Sat Feb 14 12:17:15 UTC 2026


On Sat, 14 Feb 2026 12:11:36 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

>> Color.web(string, double) parses a color string by creating substrings of the input. These string allocations can be removed.
>> 
>> There are no new tests for the `Color` class, since the existing tests already cover all relevant code paths.
>
> Michael Strauß has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - review comment
>  - review comment

I've changed the previous approach of using `s * Math.pow(10.0, e)` in favor of using [Lemire's algorithm](https://arxiv.org/pdf/2101.11408) for 64-bit significands, which guarantees correct rounding. This means that this parser will now return exactly the same doubles as `Double.parseDouble()` for 64-bit significands (bitwise identical). If the input string's significand has more digits, the result may not be bit-for-bit identical to `Double.parseDouble()`, but I think we can live with that.

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

PR Comment: https://git.openjdk.org/jfx/pull/2069#issuecomment-3901806830


More information about the openjfx-dev mailing list