1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 09:13:08 +00:00

Small update to pop_1st_bit()

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>
This commit is contained in:
Marco Costalba 2009-11-10 08:55:52 +01:00
parent 16626dd655
commit 8a116ce691

View 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]); ret = Square(BitTable[((u->dw.l ^ (u->dw.l - 1)) * 0x783a9b23) >> 26]);
u.dw.l &= (u.dw.l - 1); u->dw.l &= (u->dw.l - 1);
*bb = u.b;
return ret; return ret;
} }
ret = Square(BitTable[((~(u.dw.h ^ (u.dw.h - 1))) * 0x783a9b23) >> 26]); ret = Square(BitTable[((~(u->dw.h ^ (u->dw.h - 1))) * 0x783a9b23) >> 26]);
u.dw.h &= (u.dw.h - 1); u->dw.h &= (u->dw.h - 1);
*bb = u.b;
return ret; return ret;
} }