Slight StructuredData optimization

This commit is contained in:
momo5502 2016-11-06 12:23:20 +01:00
parent 708a739650
commit e3b96b3586

View File

@ -46,22 +46,20 @@ namespace Components
// Rebase or add new entries // Rebase or add new entries
for (auto entry : entries) for (auto entry : entries)
{ {
bool rebased = false; const char* value = nullptr;
for (auto i = dataVector.begin(); i != dataVector.end(); ++i) for (auto i = dataVector.begin(); i != dataVector.end(); ++i)
{ {
if (*i == entry) if (*i == entry)
{ {
const char* value = *i; value = *i;
dataVector.erase(i); dataVector.erase(i);
dataVector.push_back(value); Logger::Print("Playerdatadef entry '%s' will be rebased!\n", value);
Logger::Print("Playerdatadef entry '%s' was rebased!\n", value);
rebased = true;
break; break;
} }
} }
if(rebased) continue; if (!value) value = StructuredData::MemAllocator.DuplicateString(entry);
dataVector.push_back(StructuredData::MemAllocator.DuplicateString(entry)); dataVector.push_back(value);
} }
// Map data back to the game structure // Map data back to the game structure