2021-06-11 14:02:28 +02:00
|
|
|
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/EnumProperty.java b/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java
|
2024-10-22 22:00:33 +02:00
|
|
|
index e0259a3f66248b011276b6bc5135c5fc96446640..85a197232be9377c0313ec00e8f935551e2c60e0 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- 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
|
2024-10-22 22:00:33 +02:00
|
|
|
@@ -59,8 +59,7 @@ public final class EnumProperty<T extends Enum<T> & StringRepresentable> extends
|
|
|
|
return this.ordinalToIndex[enum_.ordinal()];
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
- public boolean equals(Object object) {
|
2024-01-22 19:01:10 +01:00
|
|
|
+ public boolean equals_unused(Object object) { // Paper - Perf: Optimize hashCode/equals
|
2021-06-11 14:02:28 +02:00
|
|
|
if (this == object) {
|
|
|
|
return true;
|
2023-09-21 22:35:39 +02:00
|
|
|
} else {
|
2021-06-11 14:02:28 +02:00
|
|
|
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
|
2024-10-22 22:00:33 +02:00
|
|
|
index 96798f09abe9676679bb25c74942810919e71924..55a87592a99105dbf57b26fb6ccba695295fce24 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- 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
|
2024-10-22 22:00:33 +02:00
|
|
|
@@ -28,8 +28,7 @@ public final class IntegerProperty extends Property<Integer> {
|
2021-06-11 14:02:28 +02:00
|
|
|
return this.values;
|
|
|
|
}
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
- public boolean equals(Object object) {
|
2024-01-22 19:01:10 +01:00
|
|
|
+ public boolean equals_unused(Object object) { // Paper - Perf: Optimize hashCode/equals
|
2021-06-11 14:02:28 +02:00
|
|
|
if (this == object) {
|
|
|
|
return true;
|
2023-09-21 22:35:39 +02:00
|
|
|
} else {
|
2021-06-11 14:02:28 +02:00
|
|
|
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
|
2024-10-22 22:00:33 +02:00
|
|
|
index e2bf1055d9ee09c29884505112ccc748cc049bfc..fcf04c5c58ff35d38c5bf0df562ae2f8dc98a0ee 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- 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
|
2024-10-22 22:00:33 +02:00
|
|
|
@@ -72,7 +72,7 @@ public abstract class Property<T extends Comparable<T>> {
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2021-11-24 23:26:32 +01:00
|
|
|
@Override
|
2021-06-11 14:02:28 +02:00
|
|
|
public boolean equals(Object object) {
|
2024-04-12 21:14:06 +02:00
|
|
|
- return this == object || object instanceof Property<?> property && this.clazz.equals(property.clazz) && this.name.equals(property.name);
|
2024-01-22 19:01:10 +01:00
|
|
|
+ return this == object; // Paper - Perf: Optimize hashCode/equals
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
2021-11-24 23:26:32 +01:00
|
|
|
@Override
|