X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbitboard.cpp;h=e4fcb7ce438de974b17303135427868b441ad002;hp=5dd0137da39d225d34b4a41bb48279851fa29644;hb=1373a00187f9f6ee282a77a6039386c2746964b6;hpb=9ae2b6923504064da184d08b888fffb328818543 diff --git a/src/bitboard.cpp b/src/bitboard.cpp index 5dd0137d..e4fcb7ce 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -343,18 +343,16 @@ Square first_1(Bitboard b) { Square pop_1st_bit(Bitboard *bb) { - uint32_t t = uint32_t(*bb); - uint32_t* p = t ? (uint32_t*)bb : (uint32_t*)bb + 1; // Little endian only? - uint32_t b = t ? t : *p; + uint32_t a = uint32_t(*bb); + uint32_t* ptr = a ? (uint32_t*)bb : (uint32_t*)bb + 1; // Little endian only? + uint32_t b = a ? a : *ptr; + uint32_t c = ~(b ^ (b - 1)); - *p = b & (b -1); + *ptr = b & c; // clear the bit + if (a) + c = ~c; - if (t) - b ^= (b - 1); - else - b = ~(b ^ (b - 1)); - - return Square(BitTable[(b * 0x783a9b23) >> 26]); + return Square(BitTable[(c * 0x783a9b23) >> 26]); } #else