From e3b96b3586ab5bfd680a8701ae202a1102a0f697 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 6 Nov 2016 12:23:20 +0100 Subject: [PATCH] Slight StructuredData optimization --- src/Components/Modules/StructuredData.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Components/Modules/StructuredData.cpp b/src/Components/Modules/StructuredData.cpp index 7710025c..4b11200a 100644 --- a/src/Components/Modules/StructuredData.cpp +++ b/src/Components/Modules/StructuredData.cpp @@ -46,22 +46,20 @@ namespace Components // Rebase or add new entries for (auto entry : entries) { - bool rebased = false; + const char* value = nullptr; for (auto i = dataVector.begin(); i != dataVector.end(); ++i) { if (*i == entry) { - const char* value = *i; + value = *i; dataVector.erase(i); - dataVector.push_back(value); - Logger::Print("Playerdatadef entry '%s' was rebased!\n", value); - rebased = true; + Logger::Print("Playerdatadef entry '%s' will be rebased!\n", value); break; } } - if(rebased) continue; - dataVector.push_back(StructuredData::MemAllocator.DuplicateString(entry)); + if (!value) value = StructuredData::MemAllocator.DuplicateString(entry); + dataVector.push_back(value); } // Map data back to the game structure