On Mon, 9 Feb 2026 23:43:50 GMT, Andy Goryachev <[email protected]> wrote:

>> Color.web(string, double) parses a color string by creating substrings of 
>> the input. Almost all of these string allocations can be removed, except for 
>> an invocation of `Double.parseDouble(String)`, which doesn't have an 
>> overload that accepts a sub-range of the input string.
>> 
>> There are no new tests for this enhancement, since the existing tests 
>> already cover all relevant code paths.
>
> modules/javafx.graphics/src/main/java/javafx/scene/paint/Color.java line 517:
> 
>> 515:         int limit = end;
>> 516: 
>> 517:         while (start < limit && 
>> Character.isWhitespace(color.charAt(start))) {
> 
> I think this change is not equivalent: the `trim()` function (used before) 
> removes leading and trailing "spaces" which are defined as `space is defined 
> as any character whose codepoint is less than or equal to 'U+0020' (the space 
> character).`
> 
> `Character.isWhitespace()` is different:
> 
> 
> hex| trim| isWhitespace
> 0x00 W -
> 0x01 W -
> 0x02 W -
> 0x03 W -
> 0x04 W -
> 0x05 W -
> 0x06 W -
> 0x07 W -
> 0x08 W -
> 0x09 W W
> 0x0a W W
> 0x0b W W
> 0x0c W W
> 0x0d W W
> 0x0e W -
> 0x0f W -
> 0x10 W -
> 0x11 W -
> 0x12 W -
> 0x13 W -
> 0x14 W -
> 0x15 W -
> 0x16 W -
> 0x17 W -
> 0x18 W -
> 0x19 W -
> 0x1a W -
> 0x1b W -
> 0x1c W W
> 0x1d W W
> 0x1e W W
> 0x1f W W
> 0x20 W W
> 
> 
> see 
> https://github.com/andy-goryachev-oracle/Test/blob/main/test/goryachev/research/TestWhitespace.java

While that's true, I think it is irrelevant. `Color.web()` is not specified to 
just skip over non-whitespace control characters inside of a color function, 
and it is not prudent to assume that a string parsing function would silently 
skip over non-whitespace control characters by default.

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

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

Reply via email to