mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-16 17:16:11 +00:00
Speed up the BlockState hashCode method by caching (As it's Immutable). Allows some better optimisations in the future by using them as map keys
This commit is contained in:
parent
de9d202681
commit
d6bc85ccbe
@ -146,7 +146,7 @@ public class BlockState implements BlockStateHolder<BlockState> {
|
|||||||
@Override
|
@Override
|
||||||
public boolean equalsFuzzy(BlockStateHolder<?> o) {
|
public boolean equalsFuzzy(BlockStateHolder<?> o) {
|
||||||
if (this == o) {
|
if (this == o) {
|
||||||
// Added a reference equality check for
|
// Added a reference equality check for speediness
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!getBlockType().equals(o.getBlockType())) {
|
if (!getBlockType().equals(o.getBlockType())) {
|
||||||
@ -223,8 +223,13 @@ public class BlockState implements BlockStateHolder<BlockState> {
|
|||||||
return equalsFuzzy((BlockState) obj);
|
return equalsFuzzy((BlockState) obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Integer hashCodeCache = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(blockType, values);
|
if (hashCodeCache == null) {
|
||||||
|
hashCodeCache = Objects.hash(blockType, values);
|
||||||
|
}
|
||||||
|
return hashCodeCache;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user