]> git.sesse.net Git - remoteglot/commitdiff
Tiny optimization in _find_kings.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 20 Sep 2014 16:44:17 +0000 (18:44 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 20 Sep 2014 16:44:17 +0000 (18:44 +0200)
Board.pm

index f011b17510221f65774c1ae249a71243f1d451c5..8cf603d0f5be052c762d3f127d7bba87dc047196 100644 (file)
--- a/Board.pm
+++ b/Board.pm
@@ -378,6 +378,7 @@ sub _find_kings {
        my ($wkr, $wkc, $bkr, $bkc);
 
        for my $row (0..7) {
+               next unless grep { $_ eq 'K' || $_ eq 'k' } @{$board->[$row]};
                for my $col (0..7) {
                        my $piece = $board->[$row][$col];
                        if ($piece eq 'K') {