mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-19 08:36:33 +08:00
Don't need to assert for pos.is_ok() when position is constant
It's only necessary to do the checking at the end of every non-const member (including the constructors and from_fen()) of class Position. Once the post-condition of every modifier guarantees the class invariant, we don't need to verify sanity of the position as preconditions for outside callers such as movegen, search etc. For non-class types such as Move and Square we still need to assert of course. Suggested by Rein Halbersma. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -151,7 +151,6 @@ namespace {
|
||||
template<MoveType Type>
|
||||
MoveStack* generate(const Position& pos, MoveStack* mlist) {
|
||||
|
||||
assert(pos.is_ok());
|
||||
assert(!pos.in_check());
|
||||
|
||||
Color us = pos.side_to_move();
|
||||
@@ -202,7 +201,6 @@ template MoveStack* generate<MV_NON_EVASION>(const Position& pos, MoveStack* mli
|
||||
template<>
|
||||
MoveStack* generate<MV_NON_CAPTURE_CHECK>(const Position& pos, MoveStack* mlist) {
|
||||
|
||||
assert(pos.is_ok());
|
||||
assert(!pos.in_check());
|
||||
|
||||
Bitboard b, dc;
|
||||
@@ -243,7 +241,6 @@ MoveStack* generate<MV_NON_CAPTURE_CHECK>(const Position& pos, MoveStack* mlist)
|
||||
template<>
|
||||
MoveStack* generate<MV_EVASION>(const Position& pos, MoveStack* mlist) {
|
||||
|
||||
assert(pos.is_ok());
|
||||
assert(pos.in_check());
|
||||
|
||||
Bitboard b, target;
|
||||
@@ -315,8 +312,6 @@ MoveStack* generate<MV_EVASION>(const Position& pos, MoveStack* mlist) {
|
||||
template<>
|
||||
MoveStack* generate<MV_LEGAL>(const Position& pos, MoveStack* mlist) {
|
||||
|
||||
assert(pos.is_ok());
|
||||
|
||||
MoveStack *last, *cur = mlist;
|
||||
Bitboard pinned = pos.pinned_pieces();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user