From 446b24f1cffce99ef46606d4797981feaf994337 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Thu, 29 Apr 2021 11:44:45 -0700 Subject: [PATCH] Random stuff - Multiply by 31 in some hash functions - Remove unused render utility classes --- .../logistics/RedstoneLinkNetworkHandler.java | 2 +- .../create/foundation/OptionalUtil.java | 24 ------------------- .../backend/ShaderLoadingException.java | 23 ------------------ .../create/foundation/utility/Pair.java | 6 ++++- 4 files changed, 6 insertions(+), 49 deletions(-) delete mode 100644 src/main/java/com/simibubi/create/foundation/OptionalUtil.java delete mode 100644 src/main/java/com/simibubi/create/foundation/render/backend/ShaderLoadingException.java diff --git a/src/main/java/com/simibubi/create/content/logistics/RedstoneLinkNetworkHandler.java b/src/main/java/com/simibubi/create/content/logistics/RedstoneLinkNetworkHandler.java index 969ea7984..910ef68d1 100644 --- a/src/main/java/com/simibubi/create/content/logistics/RedstoneLinkNetworkHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/RedstoneLinkNetworkHandler.java @@ -52,7 +52,7 @@ public class RedstoneLinkNetworkHandler { @Override public int hashCode() { - return item.hashCode() ^ color; + return (item.hashCode() * 31) ^ color; } @Override diff --git a/src/main/java/com/simibubi/create/foundation/OptionalUtil.java b/src/main/java/com/simibubi/create/foundation/OptionalUtil.java deleted file mode 100644 index f15ec5969..000000000 --- a/src/main/java/com/simibubi/create/foundation/OptionalUtil.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.simibubi.create.foundation; - -import java.util.Optional; -import java.util.function.Supplier; - -public class OptionalUtil { - - public static Optional thenTry(Optional first, Optional thenTry) { - if (first.isPresent()) { - return first; - } else { - return thenTry; - } - } - - public static Optional thenTryLazy(Supplier> first, Supplier> thenTry) { - Optional one = first.get(); - if (one.isPresent()) { - return one; - } else { - return thenTry.get(); - } - } -} diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/ShaderLoadingException.java b/src/main/java/com/simibubi/create/foundation/render/backend/ShaderLoadingException.java deleted file mode 100644 index 50b1c916a..000000000 --- a/src/main/java/com/simibubi/create/foundation/render/backend/ShaderLoadingException.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.simibubi.create.foundation.render.backend; - -public class ShaderLoadingException extends RuntimeException { - - public ShaderLoadingException() { - } - - public ShaderLoadingException(String message) { - super(message); - } - - public ShaderLoadingException(String message, Throwable cause) { - super(message, cause); - } - - public ShaderLoadingException(Throwable cause) { - super(cause); - } - - public ShaderLoadingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } -} diff --git a/src/main/java/com/simibubi/create/foundation/utility/Pair.java b/src/main/java/com/simibubi/create/foundation/utility/Pair.java index 7941c090d..908e7047c 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/Pair.java +++ b/src/main/java/com/simibubi/create/foundation/utility/Pair.java @@ -49,7 +49,11 @@ public class Pair { @Override public int hashCode() { - return (first == null ? 0 : first.hashCode()) ^ (second == null ? 0 : second.hashCode()); + return (nullHash(first) * 31) ^ nullHash(second); + } + + int nullHash(Object o) { + return o == null ? 0 : o.hashCode(); } @Override