Optimise loom configuration, saves 1.2 seconds in my testing. #319

This commit is contained in:
modmuss50
2020-12-27 16:25:30 +00:00
committed by GitHub
parent c95e3459a4
commit 792a64e2ef
16 changed files with 252 additions and 87 deletions

View File

@@ -37,21 +37,14 @@ public class Checksum {
private static final Logger log = Logging.getLogger(Checksum.class);
public static boolean equals(File file, String checksum) {
if (file == null) {
if (file == null || !file.exists()) {
return false;
}
try {
//noinspection deprecation
HashCode hash = Files.asByteSource(file).hash(Hashing.sha1());
StringBuilder builder = new StringBuilder();
for (Byte hashBytes : hash.asBytes()) {
builder.append(Integer.toString((hashBytes & 0xFF) + 0x100, 16).substring(1));
}
log.debug("Checksum check: '" + builder.toString() + "' == '" + checksum + "'?");
return builder.toString().equals(checksum);
log.debug("Checksum check: '" + hash.toString() + "' == '" + checksum + "'?");
return hash.toString().equals(checksum);
} catch (IOException e) {
e.printStackTrace();
}