mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-06 07:21:32 +01:00
Avoid block allocation if the properties map is the same
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
25055413ff
commit
e65c9f6a79
@ -92,9 +92,7 @@ final class BlockImpl implements Block {
|
||||
|
||||
@Override
|
||||
public @NotNull Block withProperties(@NotNull Map<@NotNull String, @NotNull String> properties) {
|
||||
if (properties.isEmpty()) {
|
||||
return this;
|
||||
}
|
||||
if (properties.isEmpty()) return this;
|
||||
if (this.properties.size() == properties.size()) {
|
||||
return compute(properties); // Map should be complete
|
||||
}
|
||||
@ -171,6 +169,7 @@ final class BlockImpl implements Block {
|
||||
}
|
||||
|
||||
private Block compute(Map<String, String> properties) {
|
||||
if (this.properties.equals(properties)) return this;
|
||||
Block block = propertyEntry.get(properties);
|
||||
if (block == null)
|
||||
throw new IllegalArgumentException("Invalid properties: " + properties + " for block " + this);
|
||||
|
Loading…
Reference in New Issue
Block a user