Skip to content

Commit

Permalink
Avoid calling List.contains as it is O(n) (#787)
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt authored Nov 20, 2024
1 parent 2afac6c commit 35ea64a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions xplat/src/main/java/dev/emi/emi/registry/EmiTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static <T> EmiIngredient getIngredient(Class<T> clazz, List<EmiStack> sta
if (keys != null) {
for (TagKey<T> key : keys) {
List<T> values = (List<T>) TAG_CONTENTS.get(key);
map.keySet().removeAll(values);
values.forEach(map::remove);
}
} else {
keys = Lists.newArrayList();
Expand All @@ -117,7 +117,7 @@ public static <T> EmiIngredient getIngredient(Class<T> clazz, List<EmiStack> sta
continue;
}
if (map.keySet().containsAll(values)) {
map.keySet().removeAll(values);
values.forEach(map::remove);
keys.add(key);
}
if (map.isEmpty()) {
Expand Down

0 comments on commit 35ea64a

Please sign in to comment.