memory related refactor

This commit is contained in:
MihailRis
2024-05-13 00:11:20 +03:00
parent 8054d4ba55
commit 017c8722ae
25 changed files with 336 additions and 320 deletions
+6 -4
View File
@@ -33,8 +33,10 @@ ContentLUT::ContentLUT(const Content* content, size_t blocksCount, size_t itemsC
}
}
ContentLUT* ContentLUT::create(const fs::path& filename,
const Content* content) {
std::shared_ptr<ContentLUT> ContentLUT::create(
const fs::path& filename,
const Content* content
) {
auto root = files::read_json(filename);
auto blocklist = root->list("blocks");
auto itemlist = root->list("items");
@@ -47,7 +49,7 @@ ContentLUT* ContentLUT::create(const fs::path& filename,
? std::max(itemlist->size(), indices->countItemDefs())
: indices->countItemDefs();
auto lut = std::make_unique<ContentLUT>(content, blocks_c, items_c);
auto lut = std::make_shared<ContentLUT>(content, blocks_c, items_c);
if (blocklist) {
for (size_t i = 0; i < blocklist->size(); i++) {
@@ -74,7 +76,7 @@ ContentLUT* ContentLUT::create(const fs::path& filename,
}
if (lut->hasContentReorder() || lut->hasMissingContent()) {
return lut.release();
return lut;
} else {
return nullptr;
}