]> git.sesse.net Git - remoteglot/blobdiff - Board.pm
Tiny optimization in _find_kings.
[remoteglot] / 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') {