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:
@@ -1,6 +1,6 @@
|
||||
package org.bukkit.craftbukkit.util;
|
||||
|
||||
public abstract class LongHash {
|
||||
public class LongHash {
|
||||
public static long toLong(int msw, int lsw) {
|
||||
return ((long) msw << 32) + lsw - Integer.MIN_VALUE;
|
||||
}
|
||||
@@ -12,16 +12,4 @@ public abstract class LongHash {
|
||||
public static int lsw(long l) {
|
||||
return (int) (l & 0xFFFFFFFF) + Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
public boolean containsKey(int msw, int lsw) {
|
||||
return containsKey(toLong(msw, lsw));
|
||||
}
|
||||
|
||||
public void remove(int msw, int lsw) {
|
||||
remove(toLong(msw, lsw));
|
||||
}
|
||||
|
||||
public abstract boolean containsKey(long key);
|
||||
|
||||
public abstract void remove(long key);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user