mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 07:28:19 +01:00
Unnecessary array lookup
This commit is contained in:
parent
9ee74845e1
commit
0fc9cab6ab
@ -128,14 +128,14 @@ public class Tag<T> {
|
|||||||
return NBT.List(type, List.of(array));
|
return NBT.List(type, List.of(array));
|
||||||
}, null, path,
|
}, null, path,
|
||||||
copy != null ? ts -> {
|
copy != null ? ts -> {
|
||||||
T[] array = (T[]) new Object[ts.size()];
|
final int size = ts.size();
|
||||||
|
T[] array = (T[]) new Object[size];
|
||||||
boolean shallowCopy = true;
|
boolean shallowCopy = true;
|
||||||
for (int i = 0; i < ts.size(); i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
T t = ts.get(i);
|
final T t = ts.get(i);
|
||||||
array[i] = copy.apply(t);
|
final T copy = this.copy.apply(t);
|
||||||
if (shallowCopy && array[i] != t) {
|
if (shallowCopy && copy != t) shallowCopy = false;
|
||||||
shallowCopy = false;
|
array[i] = copy;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return shallowCopy ? List.copyOf(ts) : List.of(array);
|
return shallowCopy ? List.copyOf(ts) : List.of(array);
|
||||||
} : List::copyOf);
|
} : List::copyOf);
|
||||||
|
Loading…
Reference in New Issue
Block a user