From 1e73e7db02d05c007f8e4a3524ec3c66946f85b7 Mon Sep 17 00:00:00 2001 From: Uriel Salischiker Date: Fri, 16 Apr 2021 16:05:48 +0200 Subject: [PATCH] Clone with correct size to avoid resizing --- src/main/java/net/querz/nbt/tag/CompoundTag.java | 2 +- src/main/java/net/querz/nbt/tag/ListTag.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/querz/nbt/tag/CompoundTag.java b/src/main/java/net/querz/nbt/tag/CompoundTag.java index 6c754cd7..28145891 100644 --- a/src/main/java/net/querz/nbt/tag/CompoundTag.java +++ b/src/main/java/net/querz/nbt/tag/CompoundTag.java @@ -282,7 +282,7 @@ public int compareTo(CompoundTag o) { @Override public CompoundTag clone() { - CompoundTag copy = new CompoundTag(((int) Math.ceil(getValue().size() * 1.75f)) + 1); + CompoundTag copy = new CompoundTag((int) Math.ceil(getValue().size() * 1.33f)); for (Map.Entry> e : getValue().entrySet()) { copy.put(e.getKey(), e.getValue().clone()); } diff --git a/src/main/java/net/querz/nbt/tag/ListTag.java b/src/main/java/net/querz/nbt/tag/ListTag.java index 6f381351..955ad1a4 100644 --- a/src/main/java/net/querz/nbt/tag/ListTag.java +++ b/src/main/java/net/querz/nbt/tag/ListTag.java @@ -320,7 +320,7 @@ public int compareTo(ListTag o) { @SuppressWarnings("unchecked") @Override public ListTag clone() { - ListTag copy = new ListTag<>(((int) Math.ceil(this.size() * 1.75)) + 1); + ListTag copy = new ListTag<>(this.size()); // assure type safety for clone copy.typeClass = typeClass; for (T t : getValue()) {