Some koloboke replacements

This commit is contained in:
Sotr
2019-03-04 22:48:32 +08:00
parent a7fa67a9c3
commit 29b120b013
18 changed files with 40 additions and 26 deletions

View File

@@ -9,7 +9,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; // CraftBukkit
public class BlockMonsterEggs extends Block {
private final Block a;
private static final Map<Block, Block> b = Maps.newIdentityHashMap();
private static final Map<Block, Block> b = com.koloboke.collect.map.hash.HashObjObjMaps.getDefaultFactory().withHashConfig(com.koloboke.collect.hash.HashConfig.fromLoads(1./3., 2./3., 2./3.)).withNullKeyAllowed(true).withKeyEquivalence(com.koloboke.collect.Equivalence.identity()).newUpdatableMap();
public BlockMonsterEggs(Block block, Block.Info block_info) {
super(block_info);

View File

@@ -246,7 +246,7 @@ public class CommandDispatcher {
if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) return; // Spigot
// CraftBukkit start
// Register Vanilla commands into builtRoot as before
Map<CommandNode<CommandListenerWrapper>, CommandNode<ICompletionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
Map<CommandNode<CommandListenerWrapper>, CommandNode<ICompletionProvider>> map = com.koloboke.collect.map.hash.HashObjObjMaps.getDefaultFactory().withHashConfig(com.koloboke.collect.hash.HashConfig.fromLoads(1./3., 2./3., 2./3.)).withNullKeyAllowed(true).withKeyEquivalence(com.koloboke.collect.Equivalence.identity()).newMutableMap(); // Use identity to prevent aliasing issues // Akarin - koloboke
RootCommandNode vanillaRoot = new RootCommandNode();
RootCommandNode<CommandListenerWrapper> vanilla = entityplayer.server.vanillaCommandDispatcher.a().getRoot();

View File

@@ -101,7 +101,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
private int F;
private int G;
public final long[] d = new long[100];
protected final Map<DimensionManager, long[]> e = Maps.newIdentityHashMap();
protected final Map<DimensionManager, long[]> e = com.koloboke.collect.map.hash.HashObjObjMaps.getDefaultFactory().withHashConfig(com.koloboke.collect.hash.HashConfig.fromLoads(1./3., 2./3., 2./3.)).withNullKeyAllowed(true).withKeyEquivalence(com.koloboke.collect.Equivalence.identity()).newUpdatableMap(); // Akarin - koloboke
private KeyPair H;
private String I;
private String J;

View File

@@ -356,7 +356,7 @@ public class ProtoChunk implements IChunkAccess {
}
public Map<String, StructureStart> e() {
return Collections.unmodifiableMap(this.n);
return com.koloboke.collect.map.hash.HashObjObjMaps.newImmutableMap(this.n); // Akarin - koloboke
}
public void a(Map<String, StructureStart> map) {
@@ -478,7 +478,7 @@ public class ProtoChunk implements IChunkAccess {
}
public Map<BlockPosition, NBTTagCompound> w() {
return Collections.unmodifiableMap(this.i);
return com.koloboke.collect.map.hash.HashObjObjMaps.newImmutableMap(this.i); // Akarin - koloboke
}
public NBTTagCompound g(BlockPosition blockposition) {

View File

@@ -3,6 +3,8 @@ package net.minecraft.server;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.koloboke.collect.map.hash.HashObjIntMap;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
@@ -11,7 +13,7 @@ import javax.annotation.Nullable;
public class RegistryBlockID<T> implements Registry<T> {
private int a;
private final IdentityHashMap<T, Integer> b;
private final HashObjIntMap<T> b; // Akarin - IdentityHashMap -> HashObjIntMap
private final List<T> c;
public RegistryBlockID() {
@@ -20,7 +22,7 @@ public class RegistryBlockID<T> implements Registry<T> {
public RegistryBlockID(int i) {
this.c = Lists.newArrayListWithExpectedSize(i);
this.b = new IdentityHashMap(i);
this.b = com.koloboke.collect.map.hash.HashObjIntMaps.getDefaultFactory().withHashConfig(com.koloboke.collect.hash.HashConfig.fromLoads(1./3., 2./3., 2./3.)).withNullKeyAllowed(true).withKeyEquivalence(com.koloboke.collect.Equivalence.identity()).newUpdatableMap(i); // Akarin - koloboke
}
public void a(T t0, int i) {

View File

@@ -74,7 +74,7 @@ public class RegistryMaterials<V> implements IRegistry<V> {
}
public Set<MinecraftKey> keySet() {
return Collections.unmodifiableSet(this.c.keySet());
return com.koloboke.collect.set.hash.HashObjSets.newImmutableSet(this.c.keySet()); // Akarin - koloboke
}
public boolean d() {

View File

@@ -1384,8 +1384,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
timings.tileEntityTick.startTiming(); // Spigot
if (!this.tileEntityListUnload.isEmpty()) {
// Paper start - Use alternate implementation with faster contains
java.util.Set<TileEntity> toRemove = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>());
toRemove.addAll(tileEntityListUnload);
java.util.Set<TileEntity> toRemove = com.koloboke.collect.set.hash.HashObjSets.getDefaultFactory().withHashConfig(com.koloboke.collect.hash.HashConfig.fromLoads(1./3., 2./3., 2./3.)).withNullKeyAllowed(true).withEquivalence(com.koloboke.collect.Equivalence.identity()).newImmutableSet(tileEntityListUnload); // Akarin - koloboke
//toRemove.addAll(tileEntityListUnload); // Akarin - koloboke
this.tileEntityListTick.removeAll(toRemove);
// Paper end
//this.tileEntityList.removeAll(this.tileEntityListUnload); // Paper - remove unused list

View File

@@ -81,7 +81,7 @@ public class WorldData {
this.Q = 15;
this.R = Sets.newHashSet();
this.S = Sets.newLinkedHashSet();
this.T = Maps.newIdentityHashMap();
this.T = com.koloboke.collect.map.hash.HashObjObjMaps.getDefaultFactory().withHashConfig(com.koloboke.collect.hash.HashConfig.fromLoads(1./3., 2./3., 2./3.)).withNullKeyAllowed(true).withKeyEquivalence(com.koloboke.collect.Equivalence.identity()).newUpdatableMap(); // Akarin - koloboke
this.V = new GameRules();
this.p = null;
this.q = 1631;
@@ -98,7 +98,7 @@ public class WorldData {
this.Q = 15;
this.R = Sets.newHashSet();
this.S = Sets.newLinkedHashSet();
this.T = Maps.newIdentityHashMap();
this.T = com.koloboke.collect.map.hash.HashObjObjMaps.getDefaultFactory().withHashConfig(com.koloboke.collect.hash.HashConfig.fromLoads(1./3., 2./3., 2./3.)).withNullKeyAllowed(true).withKeyEquivalence(com.koloboke.collect.Equivalence.identity()).newUpdatableMap(); // Akarin - koloboke
this.V = new GameRules();
this.p = datafixer;
NBTTagCompound nbttagcompound2;
@@ -270,7 +270,7 @@ public class WorldData {
this.Q = 15;
this.R = Sets.newHashSet();
this.S = Sets.newLinkedHashSet();
this.T = Maps.newIdentityHashMap();
this.T = com.koloboke.collect.map.hash.HashObjObjMaps.getDefaultFactory().withHashConfig(com.koloboke.collect.hash.HashConfig.fromLoads(1./3., 2./3., 2./3.)).withNullKeyAllowed(true).withKeyEquivalence(com.koloboke.collect.Equivalence.identity()).newUpdatableMap(); // Akarin - koloboke
this.V = new GameRules();
this.p = null;
this.q = 1631;