Add iterator cache to UnsafeList and use it in hotspots

Adds a specialized iterator for the list and a pool of iterators to avoid
object churn. Also optimizes the clear() method to reduce object creation.
This commit is contained in:
Travis Watkins
2012-08-17 12:55:33 -05:00
parent 6d777ade16
commit 858d36efc9
4 changed files with 120 additions and 20 deletions

View File

@@ -4,10 +4,14 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.bukkit.craftbukkit.util.UnsafeList; // CraftBukkit
public class PathfinderGoalSelector {
private List a = new ArrayList();
private List b = new ArrayList();
// CraftBukkit start - ArrayList -> UnsafeList
private List a = new UnsafeList();
private List b = new UnsafeList();
// CraftBukkit end
private final MethodProfiler c;
private int d = 0;
private int e = 3;
@@ -21,7 +25,7 @@ public class PathfinderGoalSelector {
}
public void a() {
ArrayList arraylist = new ArrayList();
UnsafeList arraylist = new UnsafeList(); // CraftBukkit - ArrayList -> UnsafeList
Iterator iterator;
PathfinderGoalSelectorItem pathfindergoalselectoritem;