mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-17 07:36:23 +08:00
Micro optimize copy of new state in do_move()
Instead of copying all, copy only the fields that are updated incrementally, not the ones that are recalcuated form scratch anyway. This reduces copy overhead of 30%. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -707,10 +707,17 @@ void Position::do_move(Move m, StateInfo& newSt, Bitboard dcCandidates) {
|
||||
assert(is_ok());
|
||||
assert(move_is_ok(m));
|
||||
|
||||
// Copy some fields of old state to our new StateInfo object (except the
|
||||
// captured piece, which is taken care of later) and switch state pointer
|
||||
// to point to the new, ready to be updated, state.
|
||||
newSt = *st;
|
||||
// Copy some fields of old state to our new StateInfo object except the
|
||||
// ones which are recalculated from scratch anyway, then switch our state
|
||||
// pointer to point to the new, ready to be updated, state.
|
||||
struct ReducedStateInfo {
|
||||
Key key, pawnKey, materialKey;
|
||||
int castleRights, rule50;
|
||||
Square epSquare;
|
||||
Value mgValue, egValue;
|
||||
};
|
||||
|
||||
memcpy(&newSt, st, sizeof(ReducedStateInfo));
|
||||
newSt.capture = NO_PIECE_TYPE;
|
||||
newSt.previous = st;
|
||||
st = &newSt;
|
||||
|
||||
Reference in New Issue
Block a user