RFR: JDK-8292276 : Missing color names in CSS. [v2]
ScientificWare
duke at openjdk.org
Mon Aug 15 17:57:12 UTC 2022
On Fri, 12 Aug 2022 09:48:54 GMT, ExE Boss <duke at openjdk.org> wrote:
>> ScientificWare has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Adds to CSS.java the missing color names.
>>
>> Adds to CSS.java, the missing color names defined by :
>> CSS Color Module Level 4
>> W3C Candidate Recommendation Snapshot, 5 July 2022
>> [7.1 Named Colors](https://www.w3.org/TR/css-color-4/#named-color)
>> - Updates, Copyright year.
>> - Adds relative imports.
>> - Replaces, if ... then ... else statements with TreeMap called "colorNamed".
>> Code is more readable and easy to maintain.
>> After tests, HashMap seems slower than TreeMap. Results are available at https://github.com/scientificware/jdk/issues/12#issuecomment-1213978168.
>>
>> Warning : The Previous JDK CSS Orange Color is different from CSS Color Recommendation.
>
> src/java.desktop/share/classes/javax/swing/text/html/CSS.java line 1703:
>
>> 1701: color = hexToColor("#f5f5f5");
>> 1702: else if (str.equalsIgnoreCase("Yellowgreen"))
>> 1703: color = hexToColor("#9acd32");
>
> This should probably use <code>switch([str.toLowerCase][String::toLowerCase]([Locale.ROOT]))</code> instead of a linear search.
>
> [String::toLowerCase]: https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/lang/String.html#toLowerCase(java.util.Locale)
> [Locale.ROOT]: https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/util/Locale.html#ROOT
Hello @ExE-Boss,
A new implementation based on your comments and some performance tests.
-------------
PR: https://git.openjdk.org/jdk/pull/9825
More information about the client-libs-dev
mailing list