From 8e1446e7c9c2e80d62640d53f0fe458689497b5e Mon Sep 17 00:00:00 2001 From: Github Actions Date: Mon, 9 Feb 2026 12:42:34 +0300 Subject: [PATCH] Optimize map lookups with isEmpty check --- ...imize-map-lookups-with-isEmpty-check.patch | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 leaf-server/minecraft-patches/features/0294-Optimize-map-lookups-with-isEmpty-check.patch diff --git a/leaf-server/minecraft-patches/features/0294-Optimize-map-lookups-with-isEmpty-check.patch b/leaf-server/minecraft-patches/features/0294-Optimize-map-lookups-with-isEmpty-check.patch new file mode 100644 index 000000000..9f4f0269a --- /dev/null +++ b/leaf-server/minecraft-patches/features/0294-Optimize-map-lookups-with-isEmpty-check.patch @@ -0,0 +1,41 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Github Actions +Date: Mon, 9 Feb 2026 12:37:26 +0300 +Subject: [PATCH] Optimize map lookups with isEmpty check + + +diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java +index 8d092716cdcc48b829a1c0ee2e5416d648143a37..da36090b8bd290125ddedfd33e14857344e33a3c 100644 +--- a/net/minecraft/world/entity/Entity.java ++++ b/net/minecraft/world/entity/Entity.java +@@ -4771,7 +4771,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + } + + public boolean hasPassenger(Entity entity) { +- return this.passengers.contains(entity); ++ return !passengers.isEmpty() && this.passengers.contains(entity); // Leaf - Optimize map lookups with isEmpty check + } + + public boolean hasPassenger(Predicate predicate) { +diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java +index 3b3a801e632bf65b9bef5833755b2de3be1b059a..bad7d25cb3cbefcee82fe1fe30a17c851083cfce 100644 +--- a/net/minecraft/world/entity/LivingEntity.java ++++ b/net/minecraft/world/entity/LivingEntity.java +@@ -1175,7 +1175,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin + } + + public boolean hasEffect(Holder effect) { +- return this.activeEffects.containsKey(effect); ++ return !activeEffects.isEmpty() && this.activeEffects.containsKey(effect); // Leaf - Optimize map lookups with isEmpty check + } + + public @Nullable MobEffectInstance getEffect(Holder effect) { +@@ -4306,7 +4306,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin + // CraftBukkit start - collidable API + @Override + public boolean canCollideWithBukkit(Entity entity) { +- return this.isPushable() && this.collides != this.collidableExemptions.contains(entity.getUUID()); ++ return this.isPushable() && this.collides != (!this.collidableExemptions.isEmpty() && this.collidableExemptions.contains(entity.getUUID())); // Leaf - Optimize map lookups with isEmpty check + } + // CraftBukkit end +