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

@@ -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;