From daf922d928201791077f25b08e1cdb76dcf30806 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Fri, 24 Jan 2020 21:59:59 +0000 Subject: [PATCH] Performance optimisation when including nested jars --- src/main/java/net/fabricmc/loom/util/NestedJars.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/fabricmc/loom/util/NestedJars.java b/src/main/java/net/fabricmc/loom/util/NestedJars.java index 86b1131..1c13298 100644 --- a/src/main/java/net/fabricmc/loom/util/NestedJars.java +++ b/src/main/java/net/fabricmc/loom/util/NestedJars.java @@ -59,13 +59,15 @@ public class NestedJars { private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); public static boolean addNestedJars(Project project, Path modJarPath) { - if (getContainedJars(project).isEmpty()) { + List containedJars = getContainedJars(project); + + if (containedJars.isEmpty()) { return false; } File modJar = modJarPath.toFile(); - ZipUtil.addOrReplaceEntries(modJar, getContainedJars(project).stream().map(file -> new FileSource("META-INF/jars/" + file.getName(), file)).toArray(ZipEntrySource[]::new)); + ZipUtil.addOrReplaceEntries(modJar, containedJars.stream().map(file -> new FileSource("META-INF/jars/" + file.getName(), file)).toArray(ZipEntrySource[]::new)); return ZipUtil.transformEntries(modJar, single(new ZipEntryTransformerEntry("fabric.mod.json", new StringZipEntryTransformer() { @Override @@ -77,7 +79,7 @@ public class NestedJars { nestedJars = new JsonArray(); } - for (File file : getContainedJars(project)) { + for (File file : containedJars) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("file", "META-INF/jars/" + file.getName()); nestedJars.add(jsonObject);