mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-26 02:19:19 +00:00
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.
32 lines
1.3 KiB
Diff
32 lines
1.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Taiyou06 <kaandindar21@gmail.com>
|
|
Date: Tue, 9 Nov 2077 00:00:00 +0800
|
|
Subject: [PATCH] Remove stream in GateBehavior
|
|
|
|
|
|
diff --git a/net/minecraft/world/entity/ai/behavior/GateBehavior.java b/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
|
index bd31d1cac0d022a72bd536c41d1ef811886e7068..2830792cd98c0849280aa1e2116fa89f3c8d2c85 100644
|
|
--- a/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
|
+++ b/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
|
@@ -73,9 +73,19 @@ public class GateBehavior<E extends LivingEntity> implements BehaviorControl<E>
|
|
}
|
|
}
|
|
// Paper end - Perf: Remove streams from hot code
|
|
- if (this.behaviors.stream().noneMatch(behavior -> behavior.getStatus() == Behavior.Status.RUNNING)) {
|
|
+ // Leaf start - Remove more streams in GateBehavior
|
|
+ boolean hasRunningTask = false;
|
|
+ for (final BehaviorControl<? super E> behavior : this.behaviors) {
|
|
+ if (behavior.getStatus() == Behavior.Status.RUNNING) {
|
|
+ hasRunningTask = true;
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (!hasRunningTask) {
|
|
this.doStop(level, entity, gameTime);
|
|
}
|
|
+ // Leaf end - Remove more streams in GateBehavior
|
|
}
|
|
|
|
@Override
|