]> git.sesse.net Git - stockfish/commitdiff
Small update to pop_1st_bit()
authorMarco Costalba <mcostalba@gmail.com>
Tue, 10 Nov 2009 07:55:52 +0000 (08:55 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 10 Nov 2009 16:18:00 +0000 (17:18 +0100)
Avoid a 64 bit load using a pointer. It saves a couple of push/pop
instructions so advantage is only theorical, but anyway we use
pop_1st_bit() as a reference implementation for 32 bit systems so
we keep it more for documentation purposes then for other reasons.

Idea of pointer is of Eric Mullins.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/bitboard.cpp

index e0ce4d2d771fdeb2453d460fdf06755569a69b48..6f1569250a7fe6681c080733c86370fc32b46f0c 100644 (file)
@@ -348,21 +348,19 @@ union b_union {
 
 Square pop_1st_bit(Bitboard* bb) {
 
 
 Square pop_1st_bit(Bitboard* bb) {
 
-   b_union u;
+   b_union* u;
    Square ret;
 
    Square ret;
 
-   u.b = *bb;
+   u = (b_union*)bb;
 
 
-   if (u.dw.l)
+   if (u->dw.l)
    {
    {
-       ret = Square(BitTable[((u.dw.l ^ (u.dw.l - 1)) * 0x783a9b23) >> 26]);
-       u.dw.l &= (u.dw.l - 1);
-       *bb = u.b;
+       ret = Square(BitTable[((u->dw.l ^ (u->dw.l - 1)) * 0x783a9b23) >> 26]);
+       u->dw.l &= (u->dw.l - 1);
        return ret;
    }
        return ret;
    }
-   ret = Square(BitTable[((~(u.dw.h ^ (u.dw.h - 1))) * 0x783a9b23) >> 26]);
-   u.dw.h &= (u.dw.h - 1);
-   *bb = u.b;
+   ret = Square(BitTable[((~(u->dw.h ^ (u->dw.h - 1))) * 0x783a9b23) >> 26]);
+   u->dw.h &= (u->dw.h - 1);
    return ret;
 }
 
    return ret;
 }