From 6de898d8299c5205547c51336ae48f3c9399f011 Mon Sep 17 00:00:00 2001 From: Frank Busse Date: Wed, 7 Oct 2020 19:48:28 +0100 Subject: DFS/BFS/RandomSearcher: replace loop with std::find --- lib/Core/Searcher.cpp | 45 +++++++++------------------------------------ 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/lib/Core/Searcher.cpp b/lib/Core/Searcher.cpp index 0dffcf2c..5b9375f9 100644 --- a/lib/Core/Searcher.cpp +++ b/lib/Core/Searcher.cpp @@ -54,18 +54,9 @@ void DFSSearcher::update(ExecutionState *current, if (state == states.back()) { states.pop_back(); } else { - __attribute__((unused)) - bool ok = false; - - for (auto it = states.begin(), ie = states.end(); it != ie; ++it) { - if (state == *it) { - states.erase(it); - ok = true; - break; - } - } - - assert(ok && "invalid state removed"); + auto it = std::find(states.begin(), states.end(), state); + assert(it != states.end() && "invalid state removed"); + states.erase(it); } } } @@ -108,18 +99,9 @@ void BFSSearcher::update(ExecutionState *current, if (state == states.front()) { states.pop_front(); } else { - __attribute__((unused)) - bool ok = false; - - for (auto it = states.begin(), ie = states.end(); it != ie; ++it) { - if (state == *it) { - states.erase(it); - ok = true; - break; - } - } - - assert(ok && "invalid state removed"); + auto it = std::find(states.begin(), states.end(), state); + assert(it != states.end() && "invalid state removed"); + states.erase(it); } } } @@ -149,18 +131,9 @@ void RandomSearcher::update(ExecutionState *current, // remove states for (const auto state : removedStates) { - __attribute__((unused)) - bool ok = false; - - for (auto it = states.begin(), ie = states.end(); it != ie; ++it) { - if (state == *it) { - states.erase(it); - ok = true; - break; - } - } - - assert(ok && "invalid state removed"); + auto it = std::find(states.begin(), states.end(), state); + assert(it != states.end() && "invalid state removed"); + states.erase(it); } } -- cgit 1.4.1