mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-06 10:53:50 +08:00
TranspositionTable: micro optimize first cycle
In the common case (>95%) tte == replace so skip additional comparisons in this case. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
14
src/tt.cpp
14
src/tt.cpp
@@ -114,7 +114,7 @@ void TranspositionTable::store(const Position &pos, Value v, Depth d,
|
||||
writes++;
|
||||
return;
|
||||
}
|
||||
if ((tte+i)->key() == pos.get_key())
|
||||
if ((tte+i)->key() == pos.get_key()) // overwrite old
|
||||
{
|
||||
if (m == MOVE_NONE)
|
||||
m = (tte+i)->move();
|
||||
@@ -122,12 +122,12 @@ void TranspositionTable::store(const Position &pos, Value v, Depth d,
|
||||
*(tte+i) = TTEntry(pos.get_key(), v, type, d, m, generation);
|
||||
return;
|
||||
}
|
||||
if (replace->generation() == generation)
|
||||
{
|
||||
if ((tte+i)->generation() != generation || (tte+i)->depth() < replace->depth())
|
||||
replace = tte+i;
|
||||
}
|
||||
else if ((tte+i)->generation() != generation && (tte+i)->depth() < replace->depth())
|
||||
if ( i == 0 // already is (replace == tte+i), common case
|
||||
|| replace->generation() < (tte+i)->generation())
|
||||
continue;
|
||||
|
||||
if ( replace->generation() > (tte+i)->generation()
|
||||
|| (tte+i)->depth() < replace->depth())
|
||||
replace = tte+i;
|
||||
}
|
||||
*replace = TTEntry(pos.get_key(), v, type, d, m, generation);
|
||||
|
||||
Reference in New Issue
Block a user