From c3086e524988e32b6290b323fe92377c53247909 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Mon, 19 May 2025 12:35:03 -0400 Subject: [PATCH] Remove defensive copy of model location collection in replaceAll The defensive copy shouldn't be necessary, as the set is effectively immutable anyways --- .../modernfix/forge/dynresources/ModelBakeEventHelper.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/forge/src/main/java/org/embeddedt/modernfix/forge/dynresources/ModelBakeEventHelper.java b/forge/src/main/java/org/embeddedt/modernfix/forge/dynresources/ModelBakeEventHelper.java index 7a254e38..a93b57d4 100644 --- a/forge/src/main/java/org/embeddedt/modernfix/forge/dynresources/ModelBakeEventHelper.java +++ b/forge/src/main/java/org/embeddedt/modernfix/forge/dynresources/ModelBakeEventHelper.java @@ -20,12 +20,10 @@ import org.embeddedt.modernfix.util.ForwardingInclDefaultsMap; import org.jetbrains.annotations.Nullable; import java.util.AbstractSet; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; -import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -233,8 +231,7 @@ public class ModelBakeEventHelper { @Override public void replaceAll(BiFunction function) { ModernFix.LOGGER.warn("Mod '{}' is calling replaceAll on the model registry. Some hacks will be used to keep this fast, but they may not be 100% compatible.", modId); - List locations = new ArrayList<>(ourModelLocations); - for(ResourceLocation location : locations) { + for(ResourceLocation location : ourModelLocations) { /* * Fetching every model is insanely slow. So we call the function with a null object first, since it * probably isn't expecting that. If we get an exception thrown, or it returns nonnull, then we know