Paper/patches/server/0103-Optimise-BlockState-s-hashCode-equals.patch
2024-01-23 15:57:42 +01:00

73 lines
3.6 KiB
Diff

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 3084343b724098de9791bb74ffb037a499c0c430..8da64429eaf083578c672cd34f52dd42389ff396 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 - Perf: Optimize hashCode/equals
if (this == object) {
return true;
} else {
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 647e295c7761b95db6da28f6fd043ec963f27872..0a7a6c0e7635d0ada101074d4229df7edc6dd31b 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
@@ -45,8 +45,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 - Perf: Optimize hashCode/equals
if (this == object) {
return true;
} else {
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 d6c1b1817ba79a652c4094f003a7d899d4939971..cbe6e4579cc55a427dd8f8fe403478faf6d35b8f 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
@@ -35,8 +35,7 @@ public class IntegerProperty extends Property<Integer> {
return this.values;
}
- @Override
- public boolean equals(Object object) {
+ public boolean equals_unused(Object object) { // Paper - Perf: Optimize hashCode/equals
if (this == object) {
return true;
} else {
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 d1f2e29623b15fdb99ba082fd757a54fd4713761..08c2e4ba9147fbea41e0fce26ad20586832a525b 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
@@ -70,14 +70,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; // Paper - Perf: Optimize hashCode/equals
}
@Override