mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 17:19:36 +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:
parent
16626dd655
commit
8a116ce691
1 changed files with 7 additions and 9 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue