From 0dacab65eba9fb33c86cc800fe942c99d73b1550 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sun, 9 Sep 2012 10:49:25 +0200 Subject: [PATCH] Simplify generate_castle() Skipping the calls to std::min(), std::man() we get even a nice speed-up on perft. No functional change. --- src/movegen.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/movegen.cpp b/src/movegen.cpp index 8c4712df..0686bf8d 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -17,7 +17,6 @@ along with this program. If not, see . */ -#include #include #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 -- 2.39.2