-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Enums.values() method. #777
Copy link
Copy link
Closed
Labels
Description
Original issue created by ray.j.greenwell on 2011-10-31 at 07:51 PM
Just a small suggestion:
Add a method to Enums:
public static <E extends Enum<E>> ImmutableList<E> values (Class<E> clazz);
The method maintains a static weak-key Cache mapping the enum Class to an ImmutableList of the values.
This can be used instead of the inefficient Enum.values() that returns a newly allocated array every time. Arrays suck, mutability sucks, and inefficiency sucks too.
The only wrinkle is that 'base' never imports from 'collect'...
Reactions are currently unavailable