mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-19 00:26:33 +08:00
Get rid of ReducedStateInfo struct
ReducedStateInfo is a redundant struct that is also prone to errors, indeed must be updated any time is updated StateInfo. It is a trick to partial copy a StateInfo object in do_move(). This patch takes advantage of builtin macro offsetof() to directly calculate the number of quad words to copy. Note that we still use memcpy to do the actual job of copying the (48 bytes) of data. Idea by Richard Vida. No functional and no performance change.
This commit is contained in:
@@ -770,9 +770,9 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
||||
Key k = st->key;
|
||||
|
||||
// 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.
|
||||
memcpy(&newSt, st, sizeof(ReducedStateInfo));
|
||||
// which are going to be recalculated from scratch anyway, then switch our state
|
||||
// pointer to point to the new, ready to be updated, state.
|
||||
memcpy(&newSt, st, StateCopySize64 * sizeof(uint64_t));
|
||||
|
||||
newSt.previous = st;
|
||||
st = &newSt;
|
||||
|
||||
Reference in New Issue
Block a user