mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03:09 +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) {
|
||||
|
||||
b_union u;
|
||||
b_union* u;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue