Skip to content

Commit

Permalink
Simplify generate_castle()
Browse files Browse the repository at this point in the history
Skipping the calls to std::min(), std::man() we get
even a nice speed-up on perft.

No functional change.
  • Loading branch information
mcostalba committed Sep 9, 2012
1 parent 834bd9e commit 0dacab6
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/movegen.cpp
Expand Up @@ -17,7 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <algorithm>
#include <cassert>

#include "movegen.h"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0dacab6

Please sign in to comment.