3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-07 20:10:06 +01: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

Dieser Commit ist enthalten in:
Matthew Miller 2019-02-16 12:46:10 +10:00
Ursprung de9d202681
Commit d6bc85ccbe

Datei anzeigen

@ -146,7 +146,7 @@ public class BlockState implements BlockStateHolder<BlockState> {
@Override
public boolean equalsFuzzy(BlockStateHolder<?> o) {
if (this == o) {
// Added a reference equality check for
// Added a reference equality check for speediness
return true;
}
if (!getBlockType().equals(o.getBlockType())) {
@ -223,8 +223,13 @@ public class BlockState implements BlockStateHolder<BlockState> {
return equalsFuzzy((BlockState) obj);
}
private Integer hashCodeCache = null;
@Override
public int hashCode() {
return Objects.hash(blockType, values);
if (hashCodeCache == null) {
hashCodeCache = Objects.hash(blockType, values);
}
return hashCodeCache;
}
}