mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-30 12:11:35 +01:00
Optimise BlockStateEnum
This commit is contained in:
parent
eacefd4282
commit
3820e163d4
@ -30,6 +30,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
}
|
||||
|
||||
@Nullable
|
||||
diff --git a/src/main/java/net/minecraft/server/BlockStateEnum.java b/src/main/java/net/minecraft/server/BlockStateEnum.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/BlockStateEnum.java
|
||||
+++ b/src/main/java/net/minecraft/server/BlockStateEnum.java
|
||||
@@ -0,0 +0,0 @@ public class BlockStateEnum<T extends Enum<T> & INamable> extends BlockState<T>
|
||||
throw new IllegalArgumentException("Multiple values have the same name \'" + s1 + "\'");
|
||||
}
|
||||
|
||||
- this.b.put(s1, oenum);
|
||||
+ this.b.put(s1, (T) oenum);
|
||||
}
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/CommandAbstract.java b/src/main/java/net/minecraft/server/CommandAbstract.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/CommandAbstract.java
|
||||
@ -66,3 +79,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
for (ZipEntry clazzEntry; (clazzEntry = nmsZipStream.getNextEntry()) != null; ) {
|
||||
final String entryName = clazzEntry.getName();
|
||||
--
|
||||
2.7.4 (Apple Git-66)
|
||||
|
||||
|
60
Spigot-Server-Patches/Optimise-hashCode-and-equals.patch
Normal file
60
Spigot-Server-Patches/Optimise-hashCode-and-equals.patch
Normal file
@ -0,0 +1,60 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Alfie Cleveland <alfeh@me.com>
|
||||
Date: Fri, 19 Aug 2016 01:52:56 +0100
|
||||
Subject: [PATCH] Optimise hashCode and equals
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/BlockStateEnum.java b/src/main/java/net/minecraft/server/BlockStateEnum.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/BlockStateEnum.java
|
||||
+++ b/src/main/java/net/minecraft/server/BlockStateEnum.java
|
||||
@@ -0,0 +0,0 @@ public class BlockStateEnum<T extends Enum<T> & INamable> extends BlockState<T>
|
||||
private final ImmutableSet<T> a;
|
||||
private final Map<String, T> b = Maps.newHashMap();
|
||||
|
||||
+ // Paper start - BlockStateEnum is a singleton, so we can use our own hashCode
|
||||
+ private static int hashId = 0;
|
||||
+ private int hashCode;
|
||||
+ // Paper end
|
||||
+
|
||||
protected BlockStateEnum(String s, Class<T> oclass, Collection<T> collection) {
|
||||
super(s, oclass);
|
||||
this.a = ImmutableSet.copyOf(collection);
|
||||
@@ -0,0 +0,0 @@ public class BlockStateEnum<T extends Enum<T> & INamable> extends BlockState<T>
|
||||
this.b.put(s1, (T) oenum);
|
||||
}
|
||||
|
||||
+ this.hashCode = hashId++; // Paper
|
||||
}
|
||||
|
||||
public Collection<T> c() {
|
||||
@@ -0,0 +0,0 @@ public class BlockStateEnum<T extends Enum<T> & INamable> extends BlockState<T>
|
||||
return ((INamable) t0).getName();
|
||||
}
|
||||
|
||||
+ @Override // Paper - override equals as BlockStateEnum is a singleton
|
||||
public boolean equals(Object object) {
|
||||
- if (this == object) {
|
||||
- return true;
|
||||
- } else if (object instanceof BlockStateEnum && super.equals(object)) {
|
||||
- BlockStateEnum blockstateenum = (BlockStateEnum) object;
|
||||
-
|
||||
- return this.a.equals(blockstateenum.a) && this.b.equals(blockstateenum.b);
|
||||
- } else {
|
||||
- return false;
|
||||
- }
|
||||
+ return this == object;
|
||||
}
|
||||
|
||||
+ @Override // Paper - override hashCode as BlockStateEnum is a singleton
|
||||
public int hashCode() {
|
||||
- int i = super.hashCode();
|
||||
-
|
||||
- i = 31 * i + this.a.hashCode();
|
||||
- i = 31 * i + this.b.hashCode();
|
||||
- return i;
|
||||
+ return hashCode;
|
||||
}
|
||||
|
||||
public static <T extends Enum<T> & INamable> BlockStateEnum<T> of(String s, Class<T> oclass) {
|
||||
--
|
@ -45,6 +45,7 @@ import BlockFluids
|
||||
import BlockFurnace
|
||||
import BlockIceFrost
|
||||
import BlockPosition
|
||||
import BlockStateEnum
|
||||
import ChunkCache
|
||||
import ChunkProviderFlat
|
||||
import ChunkProviderGenerate
|
||||
|
Loading…
Reference in New Issue
Block a user