On Sun, 8 Feb 2026 04:24:33 GMT, Michael Strauß <[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 405:

> 403:         if (colorString.regionMatches(true, 0, "#", 0, 1)) {
> 404:             offset = 1;
> 405:         } else if (colorString.regionMatches(true, 0, "0x", 0, 2)) {

interestingly, while the code (both old and new) ignores case, the javadoc says 
nothing about case sensitivity.

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

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

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

Reply via email to