about summary refs log tree commit diff homepage
path: root/lib/Core
diff options
context:
space:
mode:
authorFrank Busse <bb0xfb@gmail.com>2020-10-07 19:48:28 +0100
committerMartinNowack <2443641+MartinNowack@users.noreply.github.com>2020-10-12 11:31:05 +0100
commit6de898d8299c5205547c51336ae48f3c9399f011 (patch)
tree6e9e0354c95c8326417977534355e5baa916cf23 /lib/Core
parent15799911c7e0c964c7d3ec6bda62626ed6d851a5 (diff)
downloadklee-6de898d8299c5205547c51336ae48f3c9399f011.tar.gz
DFS/BFS/RandomSearcher: replace loop with std::find
Diffstat (limited to 'lib/Core')
-rw-r--r--lib/Core/Searcher.cpp45
1 files 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);
   }
 }