mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2025-02-26 08:31:24 +01:00
Set load factor to 1 for deterministically sized collections
This commit is contained in:
parent
6167c3b526
commit
5bd1ef882e
@ -185,7 +185,7 @@ public abstract class MetadataRewriter {
|
|||||||
|
|
||||||
public <T extends Enum<T> & EntityType> void mapTypes(EntityType[] oldTypes, Class<T> newTypeClass) {
|
public <T extends Enum<T> & EntityType> void mapTypes(EntityType[] oldTypes, Class<T> newTypeClass) {
|
||||||
if (typeMapping == null) {
|
if (typeMapping == null) {
|
||||||
typeMapping = new Int2IntOpenHashMap(oldTypes.length);
|
typeMapping = new Int2IntOpenHashMap(oldTypes.length, 1F);
|
||||||
typeMapping.defaultReturnValue(-1);
|
typeMapping.defaultReturnValue(-1);
|
||||||
}
|
}
|
||||||
for (EntityType oldType : oldTypes) {
|
for (EntityType oldType : oldTypes) {
|
||||||
|
@ -31,11 +31,11 @@ import java.util.Map.Entry;
|
|||||||
public class ConnectionData {
|
public class ConnectionData {
|
||||||
private static final BlockChangeRecord[] A = new BlockChangeRecord[0];
|
private static final BlockChangeRecord[] A = new BlockChangeRecord[0];
|
||||||
public static BlockConnectionProvider blockConnectionProvider;
|
public static BlockConnectionProvider blockConnectionProvider;
|
||||||
static Int2ObjectMap<String> idToKey = new Int2ObjectOpenHashMap<>(8582);
|
static Int2ObjectMap<String> idToKey = new Int2ObjectOpenHashMap<>(8582, 1F);
|
||||||
static Map<String, Integer> keyToId = new HashMap<>(8582);
|
static Map<String, Integer> keyToId = new HashMap<>(8582, 1F);
|
||||||
static Int2ObjectMap<ConnectionHandler> connectionHandlerMap = new Int2ObjectOpenHashMap<>(1);
|
static Int2ObjectMap<ConnectionHandler> connectionHandlerMap = new Int2ObjectOpenHashMap<>(1);
|
||||||
static Int2ObjectMap<BlockData> blockConnectionData = new Int2ObjectOpenHashMap<>(1);
|
static Int2ObjectMap<BlockData> 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) {
|
public static void update(UserConnection user, Position position) {
|
||||||
for (BlockFace face : BlockFace.values()) {
|
for (BlockFace face : BlockFace.values()) {
|
||||||
@ -213,10 +213,10 @@ public class ConnectionData {
|
|||||||
keyToId.put(key, id);
|
keyToId.put(key, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
connectionHandlerMap = new Int2ObjectOpenHashMap<>(3650);
|
connectionHandlerMap = new Int2ObjectOpenHashMap<>(3650, 1F);
|
||||||
|
|
||||||
if (!Via.getConfig().isReduceBlockStorageMemory()) {
|
if (!Via.getConfig().isReduceBlockStorageMemory()) {
|
||||||
blockConnectionData = new Int2ObjectOpenHashMap<>(1146);
|
blockConnectionData = new Int2ObjectOpenHashMap<>(1146, 1F);
|
||||||
JsonObject mappingBlockConnections = MappingDataLoader.loadData("blockConnections.json");
|
JsonObject mappingBlockConnections = MappingDataLoader.loadData("blockConnections.json");
|
||||||
for (Entry<String, JsonElement> entry : mappingBlockConnections.entrySet()) {
|
for (Entry<String, JsonElement> entry : mappingBlockConnections.entrySet()) {
|
||||||
int id = keyToId.get(entry.getKey());
|
int id = keyToId.get(entry.getKey());
|
||||||
@ -243,7 +243,7 @@ public class ConnectionData {
|
|||||||
JsonObject blockData = MappingDataLoader.loadData("blockData.json");
|
JsonObject blockData = MappingDataLoader.loadData("blockData.json");
|
||||||
JsonArray occluding = blockData.getAsJsonArray("occluding");
|
JsonArray occluding = blockData.getAsJsonArray("occluding");
|
||||||
for (JsonElement jsonElement : occluding) {
|
for (JsonElement jsonElement : occluding) {
|
||||||
occludingStates.add(keyToId.get(jsonElement.getAsString()));
|
occludingStates.add(keyToId.get(jsonElement.getAsString()).intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ConnectorInitAction> initActions = new ArrayList<>();
|
List<ConnectorInitAction> initActions = new ArrayList<>();
|
||||||
|
@ -26,7 +26,7 @@ public class BlockIdData {
|
|||||||
reader,
|
reader,
|
||||||
new TypeToken<Map<String, String[]>>() {
|
new TypeToken<Map<String, String[]>>() {
|
||||||
}.getType()
|
}.getType()
|
||||||
));
|
), 1F);
|
||||||
fallbackReverseMapping = new HashMap<>();
|
fallbackReverseMapping = new HashMap<>();
|
||||||
for (Map.Entry<String, String[]> entry : blockIdMapping.entrySet()) {
|
for (Map.Entry<String, String[]> entry : blockIdMapping.entrySet()) {
|
||||||
for (String val : entry.getValue()) {
|
for (String val : entry.getValue()) {
|
||||||
|
@ -4,7 +4,7 @@ import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
|||||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||||
|
|
||||||
public class EntityTypeRewriter {
|
public class EntityTypeRewriter {
|
||||||
private static final Int2IntMap ENTITY_TYPES = new Int2IntOpenHashMap(93);
|
private static final Int2IntMap ENTITY_TYPES = new Int2IntOpenHashMap(83, 1F);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ENTITY_TYPES.defaultReturnValue(-1);
|
ENTITY_TYPES.defaultReturnValue(-1);
|
||||||
|
@ -33,7 +33,7 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class WorldPackets {
|
public class WorldPackets {
|
||||||
private static final IntSet VALID_BIOMES = new IntOpenHashSet(70);
|
private static final IntSet VALID_BIOMES = new IntOpenHashSet(70, 1F);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// Client will crash if it receives a invalid biome id
|
// Client will crash if it receives a invalid biome id
|
||||||
|
Loading…
Reference in New Issue
Block a user