DSP/LabelMap: Collapse DeleteLabel loop into std::find_if
Same thing, no explicit loops.
This commit is contained in:
parent
98ec2ab2ac
commit
747128b093
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "Core/DSP/LabelMap.h"
|
#include "Core/DSP/LabelMap.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -44,14 +45,13 @@ void LabelMap::RegisterLabel(const std::string& label, u16 lval, LabelType type)
|
||||||
|
|
||||||
void LabelMap::DeleteLabel(const std::string& label)
|
void LabelMap::DeleteLabel(const std::string& label)
|
||||||
{
|
{
|
||||||
for (std::vector<label_t>::iterator iter = labels.begin(); iter != labels.end(); ++iter)
|
const auto iter = std::find_if(labels.cbegin(), labels.cend(),
|
||||||
{
|
[&label](const auto& entry) { return entry.name == label; });
|
||||||
if (!label.compare(iter->name))
|
|
||||||
{
|
if (iter == labels.cend())
|
||||||
labels.erase(iter);
|
return;
|
||||||
return;
|
|
||||||
}
|
labels.erase(iter);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LabelMap::GetLabelValue(const std::string& name, u16* value, LabelType type) const
|
bool LabelMap::GetLabelValue(const std::string& name, u16* value, LabelType type) const
|
||||||
|
|
Loading…
Reference in New Issue