Skip to content

Commit

Permalink
Clone with correct size to avoid resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
urielsalis committed Apr 16, 2021
1 parent 24fea77 commit 0fc12da
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/querz/nbt/tag/CompoundTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public int compareTo(CompoundTag o) {

@Override
public CompoundTag clone() {
CompoundTag copy = new CompoundTag();
CompoundTag copy = new CompoundTag(((int) Math.ceil(getValue().size() * 1.75f)) + 1);
for (Map.Entry<String, Tag<?>> e : getValue().entrySet()) {
copy.put(e.getKey(), e.getValue().clone());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/querz/nbt/tag/ListTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public int compareTo(ListTag<T> o) {
@SuppressWarnings("unchecked")
@Override
public ListTag<T> clone() {
ListTag<T> copy = new ListTag<>(this.size());
ListTag<T> copy = new ListTag<>(((int) Math.ceil(this.size() * 1.75)) + 1);
// assure type safety for clone
copy.typeClass = typeClass;
for (T t : getValue()) {
Expand Down

0 comments on commit 0fc12da

Please sign in to comment.