mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2025-09-18 21:33:01 +00:00
103 lines
3.5 KiB
Diff
103 lines
3.5 KiB
Diff
From 1e978f42d31177642660236c40772bf8a77e141e Mon Sep 17 00:00:00 2001
|
|
From: Axel Uhl <axel.uhl@sap.com>
|
|
Date: Thu, 11 Jan 2018 10:34:56 +1100
|
|
Subject: [PATCH] Cache BlockState.hashCode
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockState.java b/src/main/java/net/minecraft/server/BlockState.java
|
|
index 60703c627..1d626ce2f 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockState.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockState.java
|
|
@@ -36,7 +36,15 @@ public abstract class BlockState<T extends Comparable<T>> implements IBlockState
|
|
}
|
|
}
|
|
|
|
+ // Spigot start
|
|
+ private int hashCode;
|
|
public int hashCode() {
|
|
- return 31 * this.a.hashCode() + this.b.hashCode();
|
|
+ int hash = hashCode;
|
|
+ if (hash == 0) {
|
|
+ hash = 31 * this.a.hashCode() + this.b.hashCode();
|
|
+ hashCode = hash;
|
|
+ }
|
|
+ return hash;
|
|
}
|
|
+ // Spigot end
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/BlockStateBoolean.java b/src/main/java/net/minecraft/server/BlockStateBoolean.java
|
|
index 5b193f48b..02b4956ec 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockStateBoolean.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockStateBoolean.java
|
|
@@ -40,7 +40,15 @@ public class BlockStateBoolean extends BlockState<Boolean> {
|
|
}
|
|
}
|
|
|
|
+ // Spigot start
|
|
+ private int hashCode;
|
|
public int hashCode() {
|
|
- return 31 * super.hashCode() + this.a.hashCode();
|
|
+ int hash = hashCode;
|
|
+ if (hash == 0) {
|
|
+ hash = 31 * super.hashCode() + this.a.hashCode();
|
|
+ hashCode = hash;
|
|
+ }
|
|
+ return hash;
|
|
}
|
|
+ // Spigot end
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/BlockStateEnum.java b/src/main/java/net/minecraft/server/BlockStateEnum.java
|
|
index 288c52c55..21ac1e066 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockStateEnum.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockStateEnum.java
|
|
@@ -58,13 +58,20 @@ public class BlockStateEnum<T extends Enum<T> & INamable> extends BlockState<T>
|
|
}
|
|
}
|
|
|
|
+ // Spigot start
|
|
+ private int hashCode;
|
|
public int hashCode() {
|
|
- int i = super.hashCode();
|
|
+ int hash = hashCode;
|
|
+ if (hash == 0) {
|
|
+ int i = super.hashCode();
|
|
|
|
- i = 31 * i + this.a.hashCode();
|
|
- i = 31 * i + this.b.hashCode();
|
|
- return i;
|
|
+ i = 31 * i + this.a.hashCode();
|
|
+ i = 31 * i + this.b.hashCode();
|
|
+ hashCode = hash = i;
|
|
+ }
|
|
+ return hash;
|
|
}
|
|
+ // Spigot end
|
|
|
|
public static <T extends Enum<T> & INamable> BlockStateEnum<T> of(String s, Class<T> oclass) {
|
|
return a(s, oclass, Predicates.alwaysTrue());
|
|
diff --git a/src/main/java/net/minecraft/server/BlockStateInteger.java b/src/main/java/net/minecraft/server/BlockStateInteger.java
|
|
index 2b7870ead..403fa144a 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockStateInteger.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockStateInteger.java
|
|
@@ -43,9 +43,17 @@ public class BlockStateInteger extends BlockState<Integer> {
|
|
}
|
|
}
|
|
|
|
+ // Spigot start
|
|
+ private int hashCode;
|
|
public int hashCode() {
|
|
- return 31 * super.hashCode() + this.a.hashCode();
|
|
+ int hash = hashCode;
|
|
+ if (hash == 0) {
|
|
+ hash = 31 * super.hashCode() + this.a.hashCode();
|
|
+ hashCode = hash;
|
|
+ }
|
|
+ return hash;
|
|
}
|
|
+ // Spigot end
|
|
|
|
public static BlockStateInteger of(String s, int i, int j) {
|
|
return new BlockStateInteger(s, i, j);
|
|
--
|
|
2.14.1
|
|
|