RFR: 8377904: Replace Double.parseDouble() with CssNumberParser
Andy Goryachev
angorya at openjdk.org
Wed Feb 25 17:38:56 UTC 2026
On Wed, 25 Feb 2026 00:33:09 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:
> Replace occurrences of `Double.parseDouble()` with `CssNumberParser.parseDouble()` in CSS-related code.
>
> As with #2069, the specification of JavaFX CSS is not changed.
>
> There are no new tests, because the existing tests already cover all affected code paths.
Some minor suggestions, otherwise looks good.
modules/javafx.graphics/src/main/java/javafx/css/CssParser.java line 608:
> 606: int trim = 2;
> 607: final String sval = token.getText();
> 608: int start = 0, end = sval.length();
very minor: final is unnecessary, and I really dislike these c-style declarations with a comma. suggestion:
String sval = token.getText();
int start = 0;
int end = sval.length();
modules/javafx.graphics/src/main/java/javafx/css/CssParser.java line 702:
> 700: private Size time(Token token) throws ParseException {
> 701: String sval = token.getText();
> 702: int start = 0, end = sval.length();
minor: same suggestion to split the declaration
modules/javafx.graphics/src/main/java/javafx/css/CssParser.java line 1176:
> 1174: double bval = 0;
> 1175: if (argType == CssLexer.NUMBER) {
> 1176: rval = clamp(0.0f, CssNumberParser.parseDouble(rtext, 0, rtext.length()) / 255.0f, 1.0f);
maybe create `CssNumberParser.parseDouble(String)` to reduce clutter in quite a few places?
-------------
PR Review: https://git.openjdk.org/jfx/pull/2087#pullrequestreview-3855648126
PR Review Comment: https://git.openjdk.org/jfx/pull/2087#discussion_r2854333389
PR Review Comment: https://git.openjdk.org/jfx/pull/2087#discussion_r2854340905
PR Review Comment: https://git.openjdk.org/jfx/pull/2087#discussion_r2854350550
More information about the openjfx-dev
mailing list