Avoid unnecessary copies

C++20
elsid 3 years ago
parent 0b5f10e41b
commit 3877d227f4
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -32,15 +32,14 @@ namespace ESM
std::map<std::pair<std::string, bool>, int> ownerMap; std::map<std::pair<std::string, bool>, int> ownerMap;
while (esm.isNextSub("FNAM") || esm.isNextSub("ONAM")) while (esm.isNextSub("FNAM") || esm.isNextSub("ONAM"))
{ {
std::string subname = esm.retSubName().toString(); const bool isFaction = (esm.retSubName() == "FNAM");
std::string owner = esm.getHString(); std::string owner = esm.getHString();
bool isFaction = (subname == "FNAM");
int count; int count;
esm.getHNT(count, "COUN"); esm.getHNT(count, "COUN");
ownerMap.insert(std::make_pair(std::make_pair(owner, isFaction), count)); ownerMap.emplace(std::make_pair(std::move(owner), isFaction), count);
} }
mStolenItems[itemid] = ownerMap; mStolenItems.insert_or_assign(std::move(itemid), std::move(ownerMap));
} }
} }

Loading…
Cancel
Save