]> git.sesse.net Git - stockfish/commitdiff
Prefer std::find over a hand-coded loop
authorJoost VandeVondele <Joost.VandeVondele@gmail.com>
Sun, 16 Apr 2017 08:48:17 +0000 (10:48 +0200)
committerJoona Kiiski <joona@zoox.com>
Mon, 17 Apr 2017 16:25:27 +0000 (09:25 -0700)
tested for no regression.

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 37378 W: 6649 L: 6556 D: 24173

No functional change.

Closes #1071

src/movegen.h

index 33177eda925934a0712cd7af0c5166a091c19764..f298fa07ba1094669e3b862517bc576848d0ca0d 100644 (file)
@@ -21,6 +21,8 @@
 #ifndef MOVEGEN_H_INCLUDED
 #define MOVEGEN_H_INCLUDED
 
 #ifndef MOVEGEN_H_INCLUDED
 #define MOVEGEN_H_INCLUDED
 
+#include <algorithm>
+
 #include "types.h"
 
 class Position;
 #include "types.h"
 
 class Position;
@@ -59,8 +61,7 @@ struct MoveList {
   const ExtMove* end() const { return last; }
   size_t size() const { return last - moveList; }
   bool contains(Move move) const {
   const ExtMove* end() const { return last; }
   size_t size() const { return last - moveList; }
   bool contains(Move move) const {
-    for (const auto& m : *this) if (m == move) return true;
-    return false;
+    return std::find(begin(), end(), move) != end();
   }
 
 private:
   }
 
 private: