RFR: 8377427: Reduce substring allocations in Color.web(String, double) [v3]
Andy Goryachev
angorya at openjdk.org
Fri Feb 13 19:43:04 UTC 2026
On Fri, 13 Feb 2026 16:01:17 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 one additional commit since the last revision:
>
> Review comments
modules/javafx.graphics/src/main/java/com/sun/javafx/css/parser/CssNumberParser.java line 46:
> 44: * This implementation is allocation-free and avoids per-digit floating-point math by accumulating
> 45: * a (truncated) base-10 significand and a base-10 exponent. It does not aim for "perfectly rounded"
> 46: * conversion for extremely long representations, but generally returns values within 2 ULPs of the
what is the source of error in this case? would it make sense to explain (even though it's not a public class)?
modules/javafx.graphics/src/main/java/com/sun/javafx/css/parser/CssNumberParser.java line 48:
> 46: * conversion for extremely long representations, but generally returns values within 2 ULPs of the
> 47: * value returned by {@link Double#parseDouble(String)}. Representations without a fractional part
> 48: * are bit-for-bit identical.
should you mention here that it parses scientific notation?
modules/javafx.graphics/src/test/java/test/com/sun/javafx/css/parser/CssNumberParserTest.java line 179:
> 177: @Test
> 178: public void roundingIsCloseToJavaLangDouble() {
> 179: var rnd = new Random(0xc0ffee);
I might recommend to generate a random seed, print it, then test. This way, the test coverage expands with each test, and the test can be repeated exactly if it fails with a particular seed.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/2069#discussion_r2805703639
PR Review Comment: https://git.openjdk.org/jfx/pull/2069#discussion_r2805706481
PR Review Comment: https://git.openjdk.org/jfx/pull/2069#discussion_r2805671130
More information about the openjfx-dev
mailing list