On Fri, 5 Jul 2024 23:06:17 GMT, Shaojin Wen <d...@openjdk.org> wrote:

> The current HexFormat defines an Enum to represent LowerCase and UpperCase
> 
> 
> class HexFormat {
>     private enum Case {
>         LOWERCASE,
>         UPPERCASE
>     }
> }
> 
> 
> This will cause the JVM to load one more class when it starts, which can be 
> seen as follows
> 
> 
> public class Startup {
>     public static void main(String[] args) {}
> }
> 
> 
> 
> java -verbose:class Startup
> 
> 
> 
> [0.094s][info][class,load] java.util.HexFormat$Case source: 
> /Users/.../jdk/modules/java.base
> 
> 
> There are only two cases here, which can be represented by boolean, which is 
> clearer and can improve the startup speed a little bit.

The internal enum representation is an unnecessary abstraction; a boolean for 
uppercase is used for all public endpoints in `isUpperCase` and `toString`, so 
using the same boolean internally makes sense.

Do you think we should call this field `ucase` or `uppercase`?

src/java.base/share/classes/java/util/HexFormat.java line 1:

> 1: /*

Copyright year needs an update

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

PR Review: https://git.openjdk.org/jdk/pull/20060#pullrequestreview-2169018970
PR Review Comment: https://git.openjdk.org/jdk/pull/20060#discussion_r1672225028

Reply via email to