]> git.sesse.net Git - stockfish/commitdiff
Simplify generate_castle()
authorMarco Costalba <mcostalba@gmail.com>
Sun, 9 Sep 2012 08:49:25 +0000 (10:49 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 9 Sep 2012 09:50:28 +0000 (11:50 +0200)
Skipping the calls to std::min(), std::man() we get
even a nice speed-up on perft.

No functional change.

src/movegen.cpp

index 8c4712dfeb4340ca696b1f4a68f0c558155e03d2..0686bf8d93aad1922859d93b19ea3ac0873be695 100644 (file)
@@ -17,7 +17,6 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include <algorithm>
 #include <cassert>
 
 #include "movegen.h"
@@ -47,9 +46,8 @@ namespace {
 
     assert(!pos.in_check());
 
-    for (Square s = std::min(kfrom, kto), e = std::max(kfrom, kto); s <= e; s++)
-        if (    s != kfrom // We are not in check
-            && (pos.attackers_to(s) & enemies))
+    for (Square s = kto; s != kfrom; s += (Square)(Side == KING_SIDE ? -1 : 1))
+        if (pos.attackers_to(s) & enemies)
             return mlist;
 
     // Because we generate only legal castling moves we need to verify that