RFR: JDK-8292276 : Missing color names in CSS. [v2]
ScientificWare
duke at openjdk.org
Mon Aug 15 21:31:17 UTC 2022
On Mon, 15 Aug 2022 19:39:14 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 1414:
>
>> 1412: }
>> 1413:
>> 1414: private static TreeMap<String, Color> colorNamed = new TreeMap<String, Color>(
>
> Why a `TreeMap` instead of just using `Map.ofEntries(…)`?
>
> --------------------------------------------------------------------------------
>
> The latter is unmodifiable and its `table` is marked as `@Stable`[^1], which means that the JIT is allowed to treat it as fully constant[^2].
>
> [^1]: https://github.com/openjdk/jdk/blob/ea2c82e74f5580f396920f9e561cbec80c03f373/src/java.base/share/classes/java/util/ImmutableCollections.java#L1164-L1170
> [^2]: https://github.com/openjdk/jdk/blob/ea2c82e74f5580f396920f9e561cbec80c03f373/src/java.base/share/classes/jdk/internal/vm/annotation/Stable.java#L64-L72
@ExE-Boss Map 35% faster than TreeMap.
-------------
PR: https://git.openjdk.org/jdk/pull/9825
More information about the client-libs-dev
mailing list