From 5bd1ef882eede6a58904c850e86143bdb01b8a56 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Mon, 8 Jun 2020 23:13:47 +0200 Subject: [PATCH] Set load factor to 1 for deterministically sized collections --- .../ViaVersion/api/rewriters/MetadataRewriter.java | 2 +- .../blockconnections/ConnectionData.java | 12 ++++++------ .../protocol1_13to1_12_2/data/BlockIdData.java | 2 +- .../data/EntityTypeRewriter.java | 2 +- .../protocol1_13to1_12_2/packets/WorldPackets.java | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/api/rewriters/MetadataRewriter.java b/common/src/main/java/us/myles/ViaVersion/api/rewriters/MetadataRewriter.java index edf6106d6..a9dfb16ef 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/rewriters/MetadataRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/api/rewriters/MetadataRewriter.java @@ -185,7 +185,7 @@ public abstract class MetadataRewriter { public & EntityType> void mapTypes(EntityType[] oldTypes, Class newTypeClass) { if (typeMapping == null) { - typeMapping = new Int2IntOpenHashMap(oldTypes.length); + typeMapping = new Int2IntOpenHashMap(oldTypes.length, 1F); typeMapping.defaultReturnValue(-1); } for (EntityType oldType : oldTypes) { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java index c2f8ac3a4..ca987d257 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java @@ -31,11 +31,11 @@ import java.util.Map.Entry; public class ConnectionData { private static final BlockChangeRecord[] A = new BlockChangeRecord[0]; public static BlockConnectionProvider blockConnectionProvider; - static Int2ObjectMap idToKey = new Int2ObjectOpenHashMap<>(8582); - static Map keyToId = new HashMap<>(8582); + static Int2ObjectMap idToKey = new Int2ObjectOpenHashMap<>(8582, 1F); + static Map keyToId = new HashMap<>(8582, 1F); static Int2ObjectMap connectionHandlerMap = new Int2ObjectOpenHashMap<>(1); static Int2ObjectMap blockConnectionData = new Int2ObjectOpenHashMap<>(1); - static IntSet occludingStates = new IntOpenHashSet(377); + static IntSet occludingStates = new IntOpenHashSet(377, 1F); public static void update(UserConnection user, Position position) { for (BlockFace face : BlockFace.values()) { @@ -213,10 +213,10 @@ public class ConnectionData { keyToId.put(key, id); } - connectionHandlerMap = new Int2ObjectOpenHashMap<>(3650); + connectionHandlerMap = new Int2ObjectOpenHashMap<>(3650, 1F); if (!Via.getConfig().isReduceBlockStorageMemory()) { - blockConnectionData = new Int2ObjectOpenHashMap<>(1146); + blockConnectionData = new Int2ObjectOpenHashMap<>(1146, 1F); JsonObject mappingBlockConnections = MappingDataLoader.loadData("blockConnections.json"); for (Entry entry : mappingBlockConnections.entrySet()) { int id = keyToId.get(entry.getKey()); @@ -243,7 +243,7 @@ public class ConnectionData { JsonObject blockData = MappingDataLoader.loadData("blockData.json"); JsonArray occluding = blockData.getAsJsonArray("occluding"); for (JsonElement jsonElement : occluding) { - occludingStates.add(keyToId.get(jsonElement.getAsString())); + occludingStates.add(keyToId.get(jsonElement.getAsString()).intValue()); } List initActions = new ArrayList<>(); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/BlockIdData.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/BlockIdData.java index b1e547384..2e914f432 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/BlockIdData.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/BlockIdData.java @@ -26,7 +26,7 @@ public class BlockIdData { reader, new TypeToken>() { }.getType() - )); + ), 1F); fallbackReverseMapping = new HashMap<>(); for (Map.Entry entry : blockIdMapping.entrySet()) { for (String val : entry.getValue()) { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/EntityTypeRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/EntityTypeRewriter.java index fa40fc5d7..a6f1f53cc 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/EntityTypeRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/EntityTypeRewriter.java @@ -4,7 +4,7 @@ import it.unimi.dsi.fastutil.ints.Int2IntMap; import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; public class EntityTypeRewriter { - private static final Int2IntMap ENTITY_TYPES = new Int2IntOpenHashMap(93); + private static final Int2IntMap ENTITY_TYPES = new Int2IntOpenHashMap(83, 1F); static { ENTITY_TYPES.defaultReturnValue(-1); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java index d57925314..6537f3453 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java @@ -33,7 +33,7 @@ import java.util.List; import java.util.Optional; public class WorldPackets { - private static final IntSet VALID_BIOMES = new IntOpenHashSet(70); + private static final IntSet VALID_BIOMES = new IntOpenHashSet(70, 1F); static { // Client will crash if it receives a invalid biome id