Files
Shiroha/shiroha-server/minecraft-patches/features/0067-Leaf-Optimize-PatchedDataComponentMap-equals.patch
T

37 lines
2.0 KiB
Diff
Raw Normal View History

2026-07-09 00:03:09 +08:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <mrhua269@gmail.com>
Date: Sat, 2 May 2026 22:26:57 +0800
Subject: [PATCH] Leaf Optimize PatchedDataComponentMap equals
This is a part of Leaf(https://github.com/Winds-Studio/Leaf/blob/db41340915c7768d726342fb29d16bc428081074/leaf-server/minecraft-patches/features/0300-Optimize-PatchedDataComponentMap-equals.patch)
Original author: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
Original license: https://github.com/Winds-Studio/Leaf/blob/db41340915c7768d726342fb29d16bc428081074/LICENSE.md
diff --git a/net/minecraft/core/component/PatchedDataComponentMap.java b/net/minecraft/core/component/PatchedDataComponentMap.java
2026-07-14 15:09:17 +08:00
index e1397bb21b20a4be1223d12eb1f50677cd9f39d5..218a8e1d2447f18e864c7a917fd26881acd020f3 100644
2026-07-09 00:03:09 +08:00
--- a/net/minecraft/core/component/PatchedDataComponentMap.java
+++ b/net/minecraft/core/component/PatchedDataComponentMap.java
@@ -222,7 +222,19 @@ public final class PatchedDataComponentMap implements DataComponentMap, org.leav
@Override
public boolean equals(final Object obj) {
- return this == obj || obj instanceof PatchedDataComponentMap otherMap && this.prototype.equals(otherMap.prototype) && this.patch.equals(otherMap.patch);
+ // return this == obj || obj instanceof PatchedDataComponentMap otherMap && this.prototype.equals(otherMap.prototype) && this.patch.equals(otherMap.patch); // Leaf - Optimize PatchedDataComponentMap equals
+ // Leaf start - Optimize PatchedDataComponentMap equals
+ if (this == obj) return true;
+ if (!(obj instanceof PatchedDataComponentMap that)) return false;
+ if (this.patch.size() != that.patch.size()) {
+ return false;
+ }
+ if (!this.prototype.equals(that.prototype)) {
+ return false;
+ }
+ if (this.patch == that.patch) return true;
+ return this.patch.equals(that.patch);
+ // Leaf end - Optimize PatchedDataComponentMap equals
}
@Override