aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0104-Optimise-BlockState-s-hashCode-equals.patch
blob: 1223b0ff35480f6d82b1aa165ca26ebec26b5532 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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 BlockState's hashCode/equals

These are singleton "single instance" objects. We can rely on
object identity checks safely.

Use a simpler optimized hashcode

diff --git a/src/main/java/net/minecraft/world/level/block/state/properties/BooleanProperty.java b/src/main/java/net/minecraft/world/level/block/state/properties/BooleanProperty.java
index 6cdb0716f2a4b29f7a5ecd109bf3c4700ebd22ad..ff1a0d125edd2ea10c870cbb62ae9aa23644b6dc 100644
--- a/src/main/java/net/minecraft/world/level/block/state/properties/BooleanProperty.java
+++ b/src/main/java/net/minecraft/world/level/block/state/properties/BooleanProperty.java
@@ -30,8 +30,7 @@ public class BooleanProperty extends Property<Boolean> {
         return value.toString();
     }
 
-    @Override
-    public boolean equals(Object object) {
+    public boolean equals_unused(Object object) { // Paper
         if (this == object) {
             return true;
         } else if (object instanceof BooleanProperty && super.equals(object)) {
diff --git a/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java b/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java
index e76591dec764d92e1a760c5208714f3c80ea8fc7..bcf8b24e9f9e9870c1a1d27c721a6a433305d55a 100644
--- a/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java
+++ b/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java
@@ -48,8 +48,7 @@ public class EnumProperty<T extends Enum<T> & StringRepresentable> extends Prope
         return value.getSerializedName();
     }
 
-    @Override
-    public boolean equals(Object object) {
+    public boolean equals_unused(Object object) { // Paper
         if (this == object) {
             return true;
         } else if (object instanceof EnumProperty && super.equals(object)) {
diff --git a/src/main/java/net/minecraft/world/level/block/state/properties/IntegerProperty.java b/src/main/java/net/minecraft/world/level/block/state/properties/IntegerProperty.java
index c3ec7f91794d802e5b9ddac3fffccce378dace68..72f508321ebffcca31240fbdd068b4d185454cbc 100644
--- a/src/main/java/net/minecraft/world/level/block/state/properties/IntegerProperty.java
+++ b/src/main/java/net/minecraft/world/level/block/state/properties/IntegerProperty.java
@@ -38,8 +38,7 @@ public class IntegerProperty extends Property<Integer> {
         return this.values;
     }
 
-    @Override
-    public boolean equals(Object object) {
+    public boolean equals_unused(Object object) { // Paper
         if (this == object) {
             return true;
         } else if (object instanceof IntegerProperty && super.equals(object)) {
diff --git a/src/main/java/net/minecraft/world/level/block/state/properties/Property.java b/src/main/java/net/minecraft/world/level/block/state/properties/Property.java
index 0dc91cfaef2bc6004270c380e673da1728287433..81b43e0b0146729a8a1c6ade82634c86cde67857 100644
--- a/src/main/java/net/minecraft/world/level/block/state/properties/Property.java
+++ b/src/main/java/net/minecraft/world/level/block/state/properties/Property.java
@@ -66,14 +66,7 @@ public abstract class Property<T extends Comparable<T>> {
 
     @Override
     public boolean equals(Object object) {
-        if (this == object) {
-            return true;
-        } else if (!(object instanceof Property)) {
-            return false;
-        } else {
-            Property<?> property = (Property)object;
-            return this.clazz.equals(property.clazz) && this.name.equals(property.name);
-        }
+        return this == object;
     }
 
     @Override