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

Andy Goryachev angorya at openjdk.org
Tue Feb 17 20:08:32 UTC 2026


On Tue, 17 Feb 2026 19:58:45 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

>> modules/javafx.graphics/src/main/java/com/sun/javafx/css/parser/CssNumberParser.java line 303:
>> 
>>> 301:      * See "Table Generation Script" in "Number Parsing at a Gigabyte per Second" (Lemire, 2021), p. 32
>>> 302:      *
>>> 303:      * @see <a href="https://arxiv.org/pdf/2101.11408">Number Parsing at a Gigabyte per Second</a>
>> 
>> is it really worth to go to all that trouble?
>> 
>> Does the CssParser re-parses the stylesheet every time a Node changes, or does it  parse the stylesheet(s) once and then works with the internal objects to apply the styles?
>
> A stylesheet is not reparsed, but inline styles are when changed. Applications might also swap out stylesheets at runtime. `Color.web()` also seems to be used in `ColorConverter`.

good point.  still, this feels like an overkill (especially in the absence of any real world measurement).

what if we use a non-allocating parsing for integer values, and as soon as we encounter a fraction or an exponent, we use the good old `Double.parseDouble()`?  just a thought.

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

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


More information about the openjfx-dev mailing list