I doubt you could measure a performance difference...
# language-proposals
I doubt you could measure a performance difference even if you tried. The amount of code is obviously a matter of opinion.. but really.. how many enum types are there in Android that you actually use? 10 ? 100 ?
­čĹŹ 4
@spand If you replace all the int constants with enums, then you'll see your app run slower because there are probably thousands of them (int constants), which all need to be allocated as soon as their classes are loaded, and as all enum are classes, you'd grow the apk size, which could be significant (remember 8GB/4GB devices are still a thing, and 1-2GB ones too) if all apps did the same. Anyway, I'm not here to rewrite Android, I'm just searching for a more concise way to deal with int constants "switches" using the
What is "slower" though? I haven't run a benchmark but I'd imagine it's negligible, and you only pay that allocation cost once. The size of adding even 1000 enum classes to your APK is probably way less than one drawable, too
A long time ago, an enum was about ~1 KiB (depending on what's in the enum etc.)
So 10,000 enums is more than a drawable
But devs shouldn't have to worry about this really
I'd love to work on a project with 10k enums. I have only 14 enums right now... #enumsmatter