mirror of https://github.com/Minestom/Minestom.git
Fix unnecessary allocations with block properties function (#1387)
This commit is contained in:
parent
b3d81f274c
commit
4a5736cc7c
|
@ -165,6 +165,7 @@ record BlockImpl(@NotNull Registry.BlockEntry registry,
|
||||||
final PropertyType[] propertyTypes = PROPERTIES_TYPE.get(id());
|
final PropertyType[] propertyTypes = PROPERTIES_TYPE.get(id());
|
||||||
assert propertyTypes != null;
|
assert propertyTypes != null;
|
||||||
final int length = propertyTypes.length;
|
final int length = propertyTypes.length;
|
||||||
|
if (length == 0) return Map.of();
|
||||||
String[] keys = new String[length];
|
String[] keys = new String[length];
|
||||||
String[] values = new String[length];
|
String[] values = new String[length];
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
|
@ -172,7 +173,7 @@ record BlockImpl(@NotNull Registry.BlockEntry registry,
|
||||||
keys[i] = property.key();
|
keys[i] = property.key();
|
||||||
values[i] = property.values().get(propertiesArray[i]);
|
values[i] = property.values().get(propertiesArray[i]);
|
||||||
}
|
}
|
||||||
return Map.class.cast(Object2ObjectMaps.unmodifiable(new Object2ObjectArrayMap<>(keys, values, length)));
|
return Object2ObjectMaps.unmodifiable(new Object2ObjectArrayMap<>(keys, values, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue