From f11473776ce7ef9e21276a2c363f87c1d99962c6 Mon Sep 17 00:00:00 2001 From: MatthewBeshay <92357869+MatthewBeshay@users.noreply.github.com> Date: Fri, 3 Apr 2026 20:40:19 +1100 Subject: [PATCH] refactor: switch CompoundTag from unordered_map to flat_map --- targets/nbt/include/nbt/CompoundTag.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/targets/nbt/include/nbt/CompoundTag.h b/targets/nbt/include/nbt/CompoundTag.h index bba689784..347b1f3e5 100644 --- a/targets/nbt/include/nbt/CompoundTag.h +++ b/targets/nbt/include/nbt/CompoundTag.h @@ -1,6 +1,6 @@ #pragma once +#include #include -#include #include "ByteArrayTag.h" #include "ByteTag.h" @@ -16,14 +16,14 @@ class CompoundTag : public Tag { private: - std::unordered_map> tags; + std::flat_map> tags; public: CompoundTag() : Tag(L"") {} CompoundTag(const std::wstring& name) : Tag(name) {} void write(DataOutput* dos) { - for (auto& [key, value] : tags) { + for (auto&& [key, value] : tags) { Tag::writeNamedTag(value.get(), dos); } dos->writeByte(Tag::TAG_End); @@ -49,7 +49,7 @@ public: std::vector getAllTags() { std::vector ret; ret.reserve(tags.size()); - for (auto& [key, value] : tags) { + for (auto&& [key, value] : tags) { ret.push_back(value.get()); } return ret; @@ -228,7 +228,7 @@ public: Tag* copy() { CompoundTag* tag = new CompoundTag(getName()); - for (auto& [key, value] : tags) { + for (auto&& [key, value] : tags) { tag->put(key, value->copy()); } return tag; @@ -239,7 +239,7 @@ public: CompoundTag* o = (CompoundTag*)obj; if (tags.size() == o->tags.size()) { - for (auto& [key, value] : tags) { + for (auto&& [key, value] : tags) { auto itFind = o->tags.find(key); if (itFind == o->tags.end() || !value->equals(itFind->second.get())) {