Change Layer code not to create superfluous std::optional entries in LayerMap

This commit is contained in:
Silent
2019-07-30 18:43:54 +02:00
parent cb4eecde52
commit 48a4b62125
2 changed files with 17 additions and 11 deletions

View File

@ -46,8 +46,14 @@ bool Layer::Exists(const ConfigLocation& location) const
bool Layer::DeleteKey(const ConfigLocation& location)
{
m_is_dirty = true;
bool had_value = m_map[location].has_value();
m_map[location].reset();
bool had_value = false;
const auto iter = m_map.find(location);
if (iter != m_map.end() && iter->second.has_value())
{
iter->second.reset();
had_value = true;
}
return had_value;
}