Skip to content
Permalink
Browse files

DSP/LabelMap: Collapse DeleteLabel loop into std::find_if

Same thing, no explicit loops.
  • Loading branch information...
lioncash committed Jun 7, 2019
1 parent 98ec2ab commit 747128b093b2b54cdd69645adc20d74f97759335
Showing with 8 additions and 8 deletions.
  1. +8 −8 Source/Core/Core/DSP/LabelMap.cpp
@@ -4,6 +4,7 @@

#include "Core/DSP/LabelMap.h"

#include <algorithm>
#include <string>
#include <vector>

@@ -44,14 +45,13 @@ void LabelMap::RegisterLabel(const std::string& label, u16 lval, LabelType type)

void LabelMap::DeleteLabel(const std::string& label)
{
for (std::vector<label_t>::iterator iter = labels.begin(); iter != labels.end(); ++iter)
{
if (!label.compare(iter->name))
{
labels.erase(iter);
return;
}
}
const auto iter = std::find_if(labels.cbegin(), labels.cend(),
[&label](const auto& entry) { return entry.name == label; });

if (iter == labels.cend())
return;

labels.erase(iter);
}

bool LabelMap::GetLabelValue(const std::string& name, u16* value, LabelType type) const

0 comments on commit 747128b

Please sign in to comment.
You can’t perform that action at this time.