From 76087d4d3d6da0e93439fa911f4af17f627dab1d Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Mon, 27 Apr 2020 14:08:37 +0100 Subject: [PATCH] Some trivial performance improvements --- .../loom/providers/MinecraftProvider.java | 12 ++---------- .../fabricmc/loom/util/ModCompileRemapper.java | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/main/java/net/fabricmc/loom/providers/MinecraftProvider.java b/src/main/java/net/fabricmc/loom/providers/MinecraftProvider.java index 860d9df..8984619 100644 --- a/src/main/java/net/fabricmc/loom/providers/MinecraftProvider.java +++ b/src/main/java/net/fabricmc/loom/providers/MinecraftProvider.java @@ -40,7 +40,6 @@ import org.gradle.api.GradleException; import org.gradle.api.Project; import org.gradle.api.logging.Logger; -import net.fabricmc.loom.util.Checksum; import net.fabricmc.loom.util.Constants; import net.fabricmc.loom.util.DependencyProvider; import net.fabricmc.loom.util.DownloadUtil; @@ -172,15 +171,8 @@ public class MinecraftProvider extends DependencyProvider { } private void downloadJars(Logger logger) throws IOException { - if (!minecraftClientJar.exists() || (!Checksum.equals(minecraftClientJar, versionInfo.downloads.get("client").sha1) && StaticPathWatcher.INSTANCE.hasFileChanged(minecraftClientJar.toPath()))) { - logger.debug("Downloading Minecraft {} client jar", minecraftVersion); - DownloadUtil.downloadIfChanged(new URL(versionInfo.downloads.get("client").url), minecraftClientJar, logger); - } - - if (!minecraftServerJar.exists() || (!Checksum.equals(minecraftServerJar, versionInfo.downloads.get("server").sha1) && StaticPathWatcher.INSTANCE.hasFileChanged(minecraftServerJar.toPath()))) { - logger.debug("Downloading Minecraft {} server jar", minecraftVersion); - DownloadUtil.downloadIfChanged(new URL(versionInfo.downloads.get("server").url), minecraftServerJar, logger); - } + DownloadUtil.downloadIfChanged(new URL(versionInfo.downloads.get("client").url), minecraftClientJar, logger); + DownloadUtil.downloadIfChanged(new URL(versionInfo.downloads.get("server").url), minecraftServerJar, logger); } private void mergeJars(Logger logger) throws IOException { diff --git a/src/main/java/net/fabricmc/loom/util/ModCompileRemapper.java b/src/main/java/net/fabricmc/loom/util/ModCompileRemapper.java index 833a621..6f8f930 100644 --- a/src/main/java/net/fabricmc/loom/util/ModCompileRemapper.java +++ b/src/main/java/net/fabricmc/loom/util/ModCompileRemapper.java @@ -26,8 +26,8 @@ package net.fabricmc.loom.util; import java.io.File; import java.io.IOException; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; +import java.util.zip.ZipFile; import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; @@ -98,15 +98,17 @@ public class ModCompileRemapper { */ private static boolean isFabricMod(Project project, Logger logger, ResolvedArtifact artifact, String notation) { File input = artifact.getFile(); - AtomicBoolean fabricMod = new AtomicBoolean(false); - project.zipTree(input).visit(f -> { - if (f.getName().endsWith("fabric.mod.json")) { + + try (ZipFile zipFile = new ZipFile(input)) { + if (zipFile.getEntry("fabric.mod.json") != null) { logger.info("Found Fabric mod in modCompile: {}", notation); - fabricMod.set(true); - f.stopVisiting(); + return true; } - }); - return fabricMod.get(); + + return false; + } catch (IOException e) { + return false; + } } private static void addToRegularCompile(Project project, Configuration regularCompile, String notation) {