CVarManager: Deduplicate repetitive names

We can just assign the repeated portion of the expression to a reference
instead of continually re-accessing the same variable, making it nicer
to read.
This commit is contained in:
Lioncash 2019-08-20 06:29:14 -04:00
parent cfced1bf0a
commit 645f20c308
1 changed files with 8 additions and 6 deletions

View File

@ -165,9 +165,10 @@ void CVarManager::serialize() {
if (m_useBinary) { if (m_useBinary) {
CVarContainer container; CVarContainer container;
for (const auto& pair : m_cvars) { for (const auto& pair : m_cvars) {
if (pair.second->isArchive() || const auto& cvar = pair.second;
(pair.second->isInternalArchivable() && pair.second->wasDeserialized() && !pair.second->hasDefaultValue())) {
container.cvars.push_back(*pair.second); if (cvar->isArchive() || (cvar->isInternalArchivable() && cvar->wasDeserialized() && !cvar->hasDefaultValue())) {
container.cvars.push_back(*cvar);
} }
} }
container.cvarCount = atUint32(container.cvars.size()); container.cvarCount = atUint32(container.cvars.size());
@ -185,9 +186,10 @@ void CVarManager::serialize() {
docWriter.setStyle(athena::io::YAMLNodeStyle::Block); docWriter.setStyle(athena::io::YAMLNodeStyle::Block);
for (const auto& pair : m_cvars) { for (const auto& pair : m_cvars) {
if (pair.second->isArchive() || const auto& cvar = pair.second;
(pair.second->isInternalArchivable() && pair.second->wasDeserialized() && !pair.second->hasDefaultValue())) {
docWriter.writeString(pair.second->name().data(), pair.second->toLiteral()); if (cvar->isArchive() || (cvar->isInternalArchivable() && cvar->wasDeserialized() && !cvar->hasDefaultValue())) {
docWriter.writeString(cvar->name().data(), cvar->toLiteral());
} }
} }