mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01:00
GraphicsMod: Avoid some object churn
We have quite a bit of allocation churn going on here, so we can emplace and move where appropriate to alleviate that a little.
This commit is contained in:
parent
7b6463ef1f
commit
e3e20df185
@ -115,37 +115,37 @@ std::string GraphicsModConfig::GetAbsolutePath() const
|
|||||||
void GraphicsModConfig::SerializeToConfig(picojson::object& json_obj) const
|
void GraphicsModConfig::SerializeToConfig(picojson::object& json_obj) const
|
||||||
{
|
{
|
||||||
picojson::object serialized_metadata;
|
picojson::object serialized_metadata;
|
||||||
serialized_metadata["title"] = picojson::value{m_title};
|
serialized_metadata.emplace("title", m_title);
|
||||||
serialized_metadata["author"] = picojson::value{m_author};
|
serialized_metadata.emplace("author", m_author);
|
||||||
serialized_metadata["description"] = picojson::value{m_description};
|
serialized_metadata.emplace("description", m_description);
|
||||||
json_obj["meta"] = picojson::value{serialized_metadata};
|
json_obj.emplace("meta", std::move(serialized_metadata));
|
||||||
|
|
||||||
picojson::array serialized_groups;
|
picojson::array serialized_groups;
|
||||||
for (const auto& group : m_groups)
|
for (const auto& group : m_groups)
|
||||||
{
|
{
|
||||||
picojson::object serialized_group;
|
picojson::object serialized_group;
|
||||||
group.SerializeToConfig(serialized_group);
|
group.SerializeToConfig(serialized_group);
|
||||||
serialized_groups.push_back(picojson::value{serialized_group});
|
serialized_groups.emplace_back(std::move(serialized_group));
|
||||||
}
|
}
|
||||||
json_obj["groups"] = picojson::value{serialized_groups};
|
json_obj.emplace("groups", std::move(serialized_groups));
|
||||||
|
|
||||||
picojson::array serialized_features;
|
picojson::array serialized_features;
|
||||||
for (const auto& feature : m_features)
|
for (const auto& feature : m_features)
|
||||||
{
|
{
|
||||||
picojson::object serialized_feature;
|
picojson::object serialized_feature;
|
||||||
feature.SerializeToConfig(serialized_feature);
|
feature.SerializeToConfig(serialized_feature);
|
||||||
serialized_features.push_back(picojson::value{serialized_feature});
|
serialized_features.emplace_back(std::move(serialized_feature));
|
||||||
}
|
}
|
||||||
json_obj["features"] = picojson::value{serialized_features};
|
json_obj.emplace("features", std::move(serialized_features));
|
||||||
|
|
||||||
picojson::array serialized_assets;
|
picojson::array serialized_assets;
|
||||||
for (const auto& asset : m_assets)
|
for (const auto& asset : m_assets)
|
||||||
{
|
{
|
||||||
picojson::object serialized_asset;
|
picojson::object serialized_asset;
|
||||||
asset.SerializeToConfig(serialized_asset);
|
asset.SerializeToConfig(serialized_asset);
|
||||||
serialized_assets.push_back(picojson::value{serialized_asset});
|
serialized_assets.emplace_back(std::move(serialized_asset));
|
||||||
}
|
}
|
||||||
json_obj["assets"] = picojson::value{serialized_assets};
|
json_obj.emplace("assets", std::move(serialized_assets));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GraphicsModConfig::DeserializeFromConfig(const picojson::value& value)
|
bool GraphicsModConfig::DeserializeFromConfig(const picojson::value& value)
|
||||||
@ -189,7 +189,7 @@ bool GraphicsModConfig::DeserializeFromConfig(const picojson::value& value)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_groups.push_back(group);
|
m_groups.push_back(std::move(group));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ bool GraphicsModConfig::DeserializeFromConfig(const picojson::value& value)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_features.push_back(feature);
|
m_features.push_back(std::move(feature));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,40 +247,36 @@ void GraphicsModConfig::SerializeToProfile(picojson::object* obj) const
|
|||||||
switch (m_source)
|
switch (m_source)
|
||||||
{
|
{
|
||||||
case Source::User:
|
case Source::User:
|
||||||
{
|
json_obj.emplace("source", "user");
|
||||||
json_obj["source"] = picojson::value{"user"};
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Source::System:
|
case Source::System:
|
||||||
{
|
json_obj.emplace("source", "system");
|
||||||
json_obj["source"] = picojson::value{"system"};
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
};
|
|
||||||
|
|
||||||
json_obj["path"] = picojson::value{m_relative_path};
|
json_obj.emplace("path", m_relative_path);
|
||||||
|
|
||||||
picojson::array serialized_groups;
|
picojson::array serialized_groups;
|
||||||
for (const auto& group : m_groups)
|
for (const auto& group : m_groups)
|
||||||
{
|
{
|
||||||
picojson::object serialized_group;
|
picojson::object serialized_group;
|
||||||
group.SerializeToProfile(&serialized_group);
|
group.SerializeToProfile(&serialized_group);
|
||||||
serialized_groups.push_back(picojson::value{serialized_group});
|
serialized_groups.emplace_back(std::move(serialized_group));
|
||||||
}
|
}
|
||||||
json_obj["groups"] = picojson::value{serialized_groups};
|
json_obj.emplace("groups", std::move(serialized_groups));
|
||||||
|
|
||||||
picojson::array serialized_features;
|
picojson::array serialized_features;
|
||||||
for (const auto& feature : m_features)
|
for (const auto& feature : m_features)
|
||||||
{
|
{
|
||||||
picojson::object serialized_feature;
|
picojson::object serialized_feature;
|
||||||
feature.SerializeToProfile(&serialized_feature);
|
feature.SerializeToProfile(&serialized_feature);
|
||||||
serialized_features.push_back(picojson::value{serialized_feature});
|
serialized_features.emplace_back(std::move(serialized_feature));
|
||||||
}
|
}
|
||||||
json_obj["features"] = picojson::value{serialized_features};
|
json_obj.emplace("features", std::move(serialized_features));
|
||||||
|
|
||||||
json_obj["enabled"] = picojson::value{m_enabled};
|
json_obj.emplace("enabled", m_enabled);
|
||||||
|
|
||||||
json_obj["weight"] = picojson::value{static_cast<double>(m_weight)};
|
json_obj.emplace("weight", static_cast<double>(m_weight));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsModConfig::DeserializeFromProfile(const picojson::object& obj)
|
void GraphicsModConfig::DeserializeFromProfile(const picojson::object& obj)
|
||||||
@ -289,7 +285,7 @@ void GraphicsModConfig::DeserializeFromProfile(const picojson::object& obj)
|
|||||||
{
|
{
|
||||||
if (it->second.is<picojson::array>())
|
if (it->second.is<picojson::array>())
|
||||||
{
|
{
|
||||||
auto serialized_groups = it->second.get<picojson::array>();
|
const auto& serialized_groups = it->second.get<picojson::array>();
|
||||||
if (serialized_groups.size() != m_groups.size())
|
if (serialized_groups.size() != m_groups.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -309,7 +305,7 @@ void GraphicsModConfig::DeserializeFromProfile(const picojson::object& obj)
|
|||||||
{
|
{
|
||||||
if (it->second.is<picojson::array>())
|
if (it->second.is<picojson::array>())
|
||||||
{
|
{
|
||||||
auto serialized_features = it->second.get<picojson::array>();
|
const auto& serialized_features = it->second.get<picojson::array>();
|
||||||
if (serialized_features.size() != m_features.size())
|
if (serialized_features.size() != m_features.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user