Skip to content

Commit

Permalink
DSP/LabelMap: Collapse DeleteLabel loop into std::find_if
Browse files Browse the repository at this point in the history
Same thing, no explicit loops.
  • Loading branch information
lioncash committed Jun 7, 2019
1 parent 98ec2ab commit 747128b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Source/Core/Core/DSP/LabelMap.cpp
Expand Up @@ -4,6 +4,7 @@


#include "Core/DSP/LabelMap.h" #include "Core/DSP/LabelMap.h"


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


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 747128b

Please sign in to comment.