mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
Cache BlockImpl hashcode
This commit is contained in:
parent
bfdc5a53ca
commit
2339fe1c07
@ -69,6 +69,8 @@ final class BlockImpl implements Block {
|
|||||||
private final NBTCompound nbt;
|
private final NBTCompound nbt;
|
||||||
private final BlockHandler handler;
|
private final BlockHandler handler;
|
||||||
|
|
||||||
|
private int hashCode; // Cache
|
||||||
|
|
||||||
BlockImpl(@NotNull Registry.BlockEntry registry,
|
BlockImpl(@NotNull Registry.BlockEntry registry,
|
||||||
@NotNull Map<Map<String, String>, Block> propertyEntry,
|
@NotNull Map<Map<String, String>, Block> propertyEntry,
|
||||||
@NotNull Map<String, String> properties,
|
@NotNull Map<String, String> properties,
|
||||||
@ -151,7 +153,12 @@ final class BlockImpl implements Block {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(stateId(), nbt, handler);
|
int result = hashCode;
|
||||||
|
if (result == 0) {
|
||||||
|
result = Objects.hash(stateId(), nbt, handler);
|
||||||
|
this.hashCode = result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user