mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-28 19:58:53 +00:00
SysConf: Return emplaced reference from AddEntry()
Allows GetOrAddEntry() to be implemented in a manner that doesn't result in a redundant lookup in the event an addition needs to be made.
This commit is contained in:
parent
74224c94a7
commit
05094ab51f
2 changed files with 5 additions and 5 deletions
|
@ -222,9 +222,9 @@ SysConf::Entry::Entry(Type type_, const std::string& name_, std::vector<u8> byte
|
|||
{
|
||||
}
|
||||
|
||||
void SysConf::AddEntry(Entry&& entry)
|
||||
SysConf::Entry& SysConf::AddEntry(Entry&& entry)
|
||||
{
|
||||
m_entries.emplace_back(std::move(entry));
|
||||
return m_entries.emplace_back(std::move(entry));
|
||||
}
|
||||
|
||||
SysConf::Entry* SysConf::GetEntry(std::string_view key)
|
||||
|
@ -245,8 +245,8 @@ SysConf::Entry* SysConf::GetOrAddEntry(std::string_view key, Entry::Type type)
|
|||
{
|
||||
if (Entry* entry = GetEntry(key))
|
||||
return entry;
|
||||
AddEntry({type, std::string(key)});
|
||||
return GetEntry(key);
|
||||
|
||||
return &AddEntry({type, std::string(key)});
|
||||
}
|
||||
|
||||
void SysConf::RemoveEntry(std::string_view key)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue