Add LongObjectHashMap and LongHashSet

Replace uses of LongHashtable and LongHashset with new implementations.
Remove EntryBase, LongBaseHashtable, LongHashset, and LongHashtable as they
are no longer used.

LongObjectHashMap does not use Entry or EntryBase classes internally for
storage so has much lower object churn and greater performance. LongHashSet
is not as much of performance win for our use case but for general use is
up to seventeen times faster than the old implementation and is in fact
faster than alternatives from "high performance" java libraries. This is
being added so that if someone tries to use it in the future in a place
unrelated to its current use they don't accidentally end up with something
slower than the Java collections HashSet implementation.
This commit is contained in:
Travis Watkins
2012-08-17 18:53:59 -05:00
parent 7b20caf8fe
commit 97ac0a3f14
10 changed files with 866 additions and 404 deletions

View File

@@ -9,7 +9,7 @@ import java.util.concurrent.Callable;
// CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.util.LongHashset;
import org.bukkit.craftbukkit.util.LongHashSet;
import org.bukkit.craftbukkit.util.UnsafeList;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.craftbukkit.CraftServer;
@@ -60,7 +60,7 @@ public abstract class World implements IBlockAccess {
// CraftBukkit start - public, longhashset
public boolean allowMonsters = true;
public boolean allowAnimals = true;
protected LongHashset chunkTickList = new LongHashset();
protected LongHashSet chunkTickList = new LongHashSet();
public long ticksPerAnimalSpawns;
public long ticksPerMonsterSpawns;
// CraftBukkit end
@@ -1057,12 +1057,12 @@ public abstract class World implements IBlockAccess {
for (i = 0; i < this.j.size(); ++i) {
entity = (Entity) this.j.get(i);
// CraftBukkit start - fixed an NPE, don't process entities in chunks queued for unload
ChunkProviderServer chunkProviderServer = ((WorldServer) entity.world).chunkProviderServer;
if (chunkProviderServer.unloadQueue.containsKey(MathHelper.floor(entity.locX) >> 4, MathHelper.floor(entity.locZ) >> 4)) {
if (entity == null) {
continue;
}
if (entity == null) {
ChunkProviderServer chunkProviderServer = ((WorldServer) entity.world).chunkProviderServer;
if (chunkProviderServer.unloadQueue.contains(MathHelper.floor(entity.locX) >> 4, MathHelper.floor(entity.locZ) >> 4)) {
continue;
}
// CraftBukkit end
@@ -1103,7 +1103,7 @@ public abstract class World implements IBlockAccess {
// CraftBukkit start - don't tick entities in chunks queued for unload
ChunkProviderServer chunkProviderServer = ((WorldServer) entity.world).chunkProviderServer;
if (chunkProviderServer.unloadQueue.containsKey(MathHelper.floor(entity.locX) >> 4, MathHelper.floor(entity.locZ) >> 4)) {
if (chunkProviderServer.unloadQueue.contains(MathHelper.floor(entity.locX) >> 4, MathHelper.floor(entity.locZ) >> 4)) {
continue;
}
// CraftBukkit end
@@ -1147,7 +1147,7 @@ public abstract class World implements IBlockAccess {
// CraftBukkit start - don't tick entities in chunks queued for unload
ChunkProviderServer chunkProviderServer = ((WorldServer) tileentity.world).chunkProviderServer;
if (chunkProviderServer.unloadQueue.containsKey(tileentity.x >> 4, tileentity.z >> 4)) {
if (chunkProviderServer.unloadQueue.contains(tileentity.x >> 4, tileentity.z >> 4)) {
continue;
}
// CraftBukkit end
@@ -1819,7 +1819,7 @@ public abstract class World implements IBlockAccess {
for (int i1 = -b0; i1 <= b0; ++i1) {
// CraftBukkit start - don't tick chunks queued for unload
ChunkProviderServer chunkProviderServer = ((WorldServer) entityhuman.world).chunkProviderServer;
if (chunkProviderServer.unloadQueue.containsKey(l + j, i1 + k)) {
if (chunkProviderServer.unloadQueue.contains(l + j, i1 + k)) {
continue;
}
// CraftBukkit end