Overview
Using entrySet() is the fastest way to get all the keys with their values.
Don't use keySet() with get()
From AnimationController.actionPerformed()
for (Part part : map.keySet()) {
if (map.get(part).isDone()) {
if (partsToRemove == null) {
partsToRemove = new ArrayList();
}
partsToRemove.add(part);
}
}
Using get() is much more expensive than Entry.getValue().
for (Map.Entry entry : map.entrySet()) {
if (entry.getValue().isDone()) {
if (partsToRemove == null) {
partsToRemove = new ArrayList();
}
partsToRemove.add(entry.getKey());
}
}
Comments
Post a Comment