Almost every core library collection class can benefit from overriding those default methods for performance. But it hasn't been done consistently - I noticed this myself recently in other collection classes; we have an effort under way to fix that for jdk9 (notably ArrayDeque). But EnumMap/EnumSet have probably fallen into the orphaned bucket.
On Tue, Dec 6, 2016 at 12:03 AM, Michael Hixson <michael.hix...@gmail.com> wrote: > Hello, > > I notice that EnumSet and EnumMap don't override any of the default > methods that were added to collections in Java 8. Were they > specifically considered then avoided during the Java 8 upgrades, or > was it simply that no one got around to optimizing them? Are there > existing issues/bugs for optimizing them? I couldn't find any. > > As one example: I suspect that EnumMap.forEach(action) could improve > a lot. Right now it looks like iterating over keySet() and calling > get(key) is faster than forEach(action) when it comes to EnumMap > (unlike every other Map implementation I tested). > > -Michael >