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 f011b17..8cf603d 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') {