9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-30 12:29:13 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0150-Remove-stream-in-matchingSlot.patch
Dreeam 9a4efaa230 Drop patch that causes performance regression
Originally vanilla logic is to use stream, and Mojang switched it to Guava's Collections2
since 1.21.4. It is much faster than using stream or manually adding to a new ArrayList.
Manually adding to a new ArrayList requires allocating a new object array. However, the Collections2
lazy handles filter condition on iteration, so much better.
2025-08-04 19:25:56 +08:00

28 lines
1.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Tue, 26 Nov 2024 19:58:29 -0500
Subject: [PATCH] Remove stream in matchingSlot
diff --git a/net/minecraft/world/item/enchantment/Enchantment.java b/net/minecraft/world/item/enchantment/Enchantment.java
index 0460da0124d2c48b7fed45fa182537fd8059135d..08c49c078d03ff142cc74b7ee7103bf3ccf41dc4 100644
--- a/net/minecraft/world/item/enchantment/Enchantment.java
+++ b/net/minecraft/world/item/enchantment/Enchantment.java
@@ -126,7 +126,15 @@ public record Enchantment(Component description, Enchantment.EnchantmentDefiniti
}
public boolean matchingSlot(EquipmentSlot slot) {
- return this.definition.slots().stream().anyMatch(equipmentSlotGroup -> equipmentSlotGroup.test(slot));
+ // Leaf start - Remove stream in matchingSlot
+ for (EquipmentSlotGroup equipmentSlotGroup : this.definition.slots()) {
+ if (equipmentSlotGroup.test(slot)) {
+ return true;
+ }
+ }
+
+ return false;
+ // Leaf end - Remove stream in matchingSlot
}
public boolean isPrimaryItem(ItemStack stack) {