Re-add comment to navigation patch

This commit is contained in:
Zach Brown 2016-03-18 21:41:50 -05:00
parent c19e52a63f
commit 148f3809ca

View file

@ -1,4 +1,4 @@
From 918a65f485c1a865b3a38ecd4e5a879d5bf786aa Mon Sep 17 00:00:00 2001 From 7a0a329dd1092b98f0951ae49af15c56d210d6d9 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Tue, 8 Mar 2016 19:13:54 -0500 Date: Tue, 8 Mar 2016 19:13:54 -0500
Subject: [PATCH] Optimize Navigation Listener Subject: [PATCH] Optimize Navigation Listener
@ -32,10 +32,10 @@ index 7d794b9..aa18f54 100644
protected abstract Pathfinder a(); protected abstract Pathfinder a();
diff --git a/src/main/java/net/minecraft/server/NavigationListener.java b/src/main/java/net/minecraft/server/NavigationListener.java diff --git a/src/main/java/net/minecraft/server/NavigationListener.java b/src/main/java/net/minecraft/server/NavigationListener.java
index f82ea80..aade479 100644 index f82ea80..963a0e7 100644
--- a/src/main/java/net/minecraft/server/NavigationListener.java --- a/src/main/java/net/minecraft/server/NavigationListener.java
+++ b/src/main/java/net/minecraft/server/NavigationListener.java +++ b/src/main/java/net/minecraft/server/NavigationListener.java
@@ -1,26 +1,32 @@ @@ -1,26 +1,35 @@
package net.minecraft.server; package net.minecraft.server;
+import java.util.ArrayList; // Paper +import java.util.ArrayList; // Paper
@ -66,13 +66,16 @@ index f82ea80..aade479 100644
- for (int k = 0; k < j; ++k) { - for (int k = 0; k < j; ++k) {
- NavigationAbstract navigationabstract = anavigationabstract1[k]; - NavigationAbstract navigationabstract = anavigationabstract1[k];
+ */ + */
+ // DO NOT USE AN ITERATOR! This must be a for (;;) to avoid CME.
+ // This is perfectly safe, as additions are ok to be done in this iteration
+ // and Removals are queued instead of immediate.
+ for (int k = 0; k < this.navigators.size(); ++k) { + for (int k = 0; k < this.navigators.size(); ++k) {
+ NavigationAbstract navigationabstract = this.navigators.get(k); + NavigationAbstract navigationabstract = this.navigators.get(k);
+ // Paper end + // Paper end
if (navigationabstract != null && !navigationabstract.i()) { if (navigationabstract != null && !navigationabstract.i()) {
PathEntity pathentity = navigationabstract.k(); PathEntity pathentity = navigationabstract.k();
@@ -55,9 +61,21 @@ public class NavigationListener implements IWorldAccess { @@ -55,9 +64,21 @@ public class NavigationListener implements IWorldAccess {
public void a(int i, boolean flag, double d0, double d1, double d2, double d3, double d4, double d5, int... aint) {} public void a(int i, boolean flag, double d0, double d1, double d2, double d3, double d4, double d5, int... aint) {}