mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-22 10:06:26 +08:00
Micro-optimize color_of()
In almost all cases we already know in advance that color_of() argument is different from NO_PIECE. So avoid the check for NO_PIECE in color_of() and test at caller site in the very few places where this case could occur. As a nice side effect, this patch fixes a (bogus) warning under some versions of gcc. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
/// | only in 64-bit mode. For compiling requires hardware with
|
||||
/// | popcnt support.
|
||||
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
@@ -391,7 +392,8 @@ inline PieceType type_of(Piece p) {
|
||||
}
|
||||
|
||||
inline Color color_of(Piece p) {
|
||||
return p == NO_PIECE ? NO_COLOR : Color(p >> 3);
|
||||
assert(p != NO_PIECE);
|
||||
return Color(p >> 3);
|
||||
}
|
||||
|
||||
inline bool is_ok(Square s) {
|
||||
|
||||
Reference in New Issue
Block a user