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

Andy Goryachev angorya at openjdk.org
Thu Feb 19 16:55:07 UTC 2026


On Thu, 19 Feb 2026 11:04:27 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.
>> 
>> CSS numbers are parsed by `CssNumberParser`, which parses CSS-compliant numbers using Lemire's algorithm.
>> 
>> 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:
> 
>   add test

modules/javafx.graphics/src/main/java/com/sun/javafx/css/parser/CssNumberParser.java line 304:

> 302:      * @see <a href="https://arxiv.org/pdf/2101.11408">Number Parsing at a Gigabyte per Second</a>
> 303:      */
> 304:     private static final long[] T = new long[] {

Warning about a large binary blob of unknown origin in the source.

I suggest we do two things here:
1. add a comment explaining what it is and how it is computed in general terms
2. provide the code that generates it, so it can be reviewed at the source level.  For example, it might be in a form of a unit test which generates the array and compares it to the one here.

modules/javafx.graphics/src/test/java/test/com/sun/javafx/css/parser/CssNumberParserTest.java line 198:

> 196:     @Test
> 197:     public void roundingIsCorrectForSubnormals() {
> 198:         int seed = new Random().nextInt();

please change to a `long seed = new Random().nextLong();`

here and elsewhere.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/2069#discussion_r2828954946
PR Review Comment: https://git.openjdk.org/jfx/pull/2069#discussion_r2828960044


More information about the openjfx-dev mailing list