mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 08:13:08 +00: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:
parent
392360e73b
commit
d786822b92
1 changed files with 7 additions and 7 deletions
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue