bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFC: help me with Java enums please


From: Paul Eggert
Subject: Re: RFC: help me with Java enums please
Date: Sat, 4 Apr 2020 10:34:54 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

On 4/4/20 12:12 AM, Akim Demaille wrote:
The JVMs are known to be quite good at optimizing, but I have no idea whether 
this abstraction will be zero-cost or not.

Although I'm no Java expert, a quick bit of Googling suggests that JVMs don't deal with enums quite as efficently as they do with ints. See, for example:

https://developer.android.com/topic/performance/reduce-apk-size

which says: "Avoid enumerations. A single enum can add about 1.0 to 1.4 KB of size to your app's classes.dex file. These additions can quickly accumulate for complex systems or shared libraries. If possible, consider using the @IntDef annotation and code shrinking to strip enumerations out and convert them to integers. This type conversion preserves all of the type safety benefits of enums."

Have you considered using @IntDef instead?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]