RFR: 8286270: [java.desktop] Replace color search in XColors with a switch statement [v2]
Alexander Zvegintsev
azvegint at openjdk.java.net
Thu May 19 18:47:12 UTC 2022
On Sat, 14 May 2022 17:33:37 GMT, SWinxy <duke at openjdk.java.net> wrote:
>> The current implementation creates ~750 new objects on load, and uses a binary array search with a Comparable implementation. This implementation is probably bad. Instead, we can use the enhanced switch feature to possibly save time, resources, and code size. The new implementation means that the array doesn't have to be sorted alphanumerically necessarily, and it creates the colors on demand.
>
> SWinxy has updated the pull request incrementally with one additional commit since the last revision:
>
> Remove @author tags per request
Changes requested by azvegint (Reviewer).
src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/XColors.java line 402:
> 400: case "olivedrab1" -> new ColorUIResource(192, 255, 62);
> 401: case "olivedrab2" -> new ColorUIResource(179, 238, 58);
> 402: case "olivedrab3", "yellow green", "yellowgreen" -> new ColorUIResource(154, 205, 50);
`yellowgreen` was originally `new XColor("yellowgreen", 154, 205, 5)`
src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/XColors.java line 487:
> 485: case "sienna3" -> new ColorUIResource(205, 104, 57);
> 486: case "sienna4" -> new ColorUIResource(139, 71, 38);
> 487: case "sky blue", "skyblue", "skyblue1" -> new ColorUIResource(135, 206, 255);
"sky blue", "skyblue" were
new XColor("sky blue", 135, 206, 235),
new XColor("skyblue", 135, 206, 235),
-------------
PR: https://git.openjdk.java.net/jdk/pull/7096
More information about the client-libs-dev
mailing list