mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-26 11:07:53 +01:00
Optimize #replace
This commit is contained in:
parent
dfeff36857
commit
59f12e1c26
@ -235,8 +235,9 @@ final class PaletteImpl implements Palette, Cloneable {
|
||||
|
||||
@Override
|
||||
public void replace(int x, int y, int z, @NotNull IntUnaryOperator operator) {
|
||||
// TODO optimize
|
||||
set(x, y, z, operator.applyAsInt(get(x, y, z)));
|
||||
final int oldValue = get(x, y, z);
|
||||
final int newValue = operator.applyAsInt(oldValue);
|
||||
if (oldValue != newValue) set(x, y, z, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user