On Tue, 10 Oct 2023 15:04:51 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:
>> src/java.desktop/share/classes/javax/swing/text/html/CSS.java line 1439: >> >>> 1437: >>> 1438: private static Map<String, Color> initColorNames() { >>> 1439: return Map.ofEntries( >> >> would it make more sense to use a switch statement instead of a static map? > >> would it make more sense to use a switch statement instead of a static map? > > I believe this was discussed somewhere… Looks like map provides better > performance compared to `switch` statement. Fetching an element from a map > gives a constant time, using a `switch` statement over strings would give a > linear search time unless it's cleverly optimised by the compiler. > > @scientificware could point you to performance measurements, if there are > ones. There were ones, if my memory serves me right. 1. I believe the switch uses hash value so it's not linear anymore 2. most of the time these colors will not be needed just a suggestion, anyway ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/9825#discussion_r1352773946