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:
Marco Costalba
2011-07-16 10:42:27 +01:00
parent 69f4954df1
commit 67686b7684
7 changed files with 13 additions and 23 deletions

View File

@@ -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();