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

Michael Strauß mstrauss at openjdk.org
Wed Feb 18 20:36:49 UTC 2026


On Wed, 18 Feb 2026 18:45:44 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

> some measurements of the improvement in parsing performance

I've run a JMH benchmark where I call `Color.web("rgb(x%, y%, z%)")` with random values. The strings are precomputed to make sure that I don't measure the string concatenation. Here are the results:

Benchmark                              Mode  Cnt     Score   Error   Units
ColorParsingPerfTest.parseColor(old)  thrpt    5   619,957 ± 5,670   ops/s
ColorParsingPerfTest.parseColor(new)  thrpt    5  1545,581 ± 13,451  ops/s


> more tests to demonstrate the correct behavior, esp. near transition points

Good point, I've added more tests especially around subnormals and limits.

> updated PR description (and possibly JBS as well) mentioning the new algorithm

I've mentioned the algorithm in the PR description.

> document the changes in behavior (a whitespace handling is one, are there other changes?)
> do the behavior differences cross the threshold for this to require a CSR?

`Color.web()` parses CSS numbers, so the current behavior is out of spec. This just brings it in line with the specification, which doesn't require a CSR.

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

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


More information about the openjfx-dev mailing list