RFR: JDK-8293776 : Adds CSS 4 and 8 digits hex coded Color [v6]

ScientificWare duke at openjdk.org
Fri Sep 23 03:35:21 UTC 2022


On Mon, 19 Sep 2022 16:41:00 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> ScientificWare has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Corrects typos and digit extraction.
>>   
>>   Corrects typos.
>>   And applies a better digit extraction as suggested in main-line review thread.
>
> src/java.desktop/share/classes/javax/swing/text/html/CSS.java line 1399:
> 
>> 1397:             final char b = digits.charAt(2);
>> 1398:             final char a = digits.charAt(3);
>> 1399:             digits = String.format("%1$s%1$s%2$s%2$s%3$s%3$s%4$s%4$s", r, g, b, a);
> 
> Does it make sense to combine these two cases into one?
> 
> Suggestion:
> 
>         if (n == 3 || n == 4) {
>             final char r = digits.charAt(0);
>             final char g = digits.charAt(1);
>             final char b = digits.charAt(2);
>             final char a = n == 4 ? digits.charAt(3) : 'f';
>             digits = String.format("%1$s%1$s%2$s%2$s%3$s%3$s%4$s%4$s", r, g, b, a);
> 
> 
> The only difference between these two case is in `a` which is hard-coded as `ff` in the format string for `n == 3`.

With this change, the code is more concise but we double the number of tests ?

-------------

PR: https://git.openjdk.org/jdk/pull/10317



More information about the client-libs-dev mailing list