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:
@@ -57,7 +57,7 @@ public class Chunk {
|
||||
this.heightMap = new int[256];
|
||||
|
||||
for (int k = 0; k < this.entitySlices.length; ++k) {
|
||||
this.entitySlices[k] = new ArrayList();
|
||||
this.entitySlices[k] = new org.bukkit.craftbukkit.util.UnsafeList(); // CraftBukkit - ArrayList -> UnsafeList
|
||||
}
|
||||
|
||||
Arrays.fill(this.b, -999);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.concurrent.Callable;
|
||||
// CraftBukkit start
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.util.LongHashset;
|
||||
import org.bukkit.craftbukkit.util.UnsafeList;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
@@ -54,7 +55,7 @@ public abstract class World implements IBlockAccess {
|
||||
public final VillageCollection villages = new VillageCollection(this);
|
||||
protected final VillageSiege siegeManager = new VillageSiege(this);
|
||||
public final MethodProfiler methodProfiler;
|
||||
private ArrayList d = new ArrayList();
|
||||
private UnsafeList d = new UnsafeList(); // CraftBukkit - ArrayList -> UnsafeList
|
||||
private boolean L;
|
||||
// CraftBukkit start - public, longhashset
|
||||
public boolean allowMonsters = true;
|
||||
@@ -112,7 +113,7 @@ public abstract class World implements IBlockAccess {
|
||||
|
||||
this.M = this.random.nextInt(12000);
|
||||
this.J = new int['\u8000'];
|
||||
this.N = new ArrayList();
|
||||
this.N = new UnsafeList(); // CraftBukkit - ArrayList -> UnsafeList
|
||||
this.isStatic = false;
|
||||
this.dataManager = idatamanager;
|
||||
this.methodProfiler = methodprofiler;
|
||||
|
||||
Reference in New Issue
Block a user