phase 1 of addressing cppcheck useStlAlgorithm warnings,

this set only includes fill and copy operations.
This commit is contained in:
G.E
2024-05-14 17:37:38 +03:00
parent 6e306a508e
commit 4cefba5ced
19 changed files with 102 additions and 98 deletions

View File

@@ -455,11 +455,10 @@ void cleanupPositions(vector<PositionInfo> &a) {
vector<PositionInfo> out;
out.reserve(a.size()); // output should be close to input in size.
for (const auto &p : a) {
if (seen.emplace(p.pos, p.flags).second) {
out.emplace_back(p); // first encounter
}
}
auto seens = [&seen=seen](const PositionInfo &p) {
return (seen.emplace(p.pos, p.flags).second);
};
std::copy_if(begin(a), end(a), std::back_inserter(out), seens);
DEBUG_PRINTF("in %zu; out %zu\n", a.size(), out.size());
a.swap(out);