Is there any inefficiency in calling the values() function of a specific enum class multiple times?
I have seen instances of existing code where the results of values() are cached for reuse. Is this useful?
public enum Blah {
private static final Blah [] _myValues = values()
...
public static Blah findBlahFromName(String name) {
for (Blah blah : _myValues) {
...
}
}
}
ImmutableMap<String,Blah>, since it's safe to share, can be wrapped, and is a bit simpler to use IMO.