mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +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++;
|
writes++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((tte+i)->key() == pos.get_key())
|
if ((tte+i)->key() == pos.get_key()) // overwrite old
|
||||||
{
|
{
|
||||||
if (m == MOVE_NONE)
|
if (m == MOVE_NONE)
|
||||||
m = (tte+i)->move();
|
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);
|
*(tte+i) = TTEntry(pos.get_key(), v, type, d, m, generation);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (replace->generation() == generation)
|
if ( i == 0 // already is (replace == tte+i), common case
|
||||||
{
|
|| replace->generation() < (tte+i)->generation())
|
||||||
if ((tte+i)->generation() != generation || (tte+i)->depth() < replace->depth())
|
continue;
|
||||||
replace = tte+i;
|
|
||||||
}
|
if ( replace->generation() > (tte+i)->generation()
|
||||||
else if ((tte+i)->generation() != generation && (tte+i)->depth() < replace->depth())
|
|| (tte+i)->depth() < replace->depth())
|
||||||
replace = tte+i;
|
replace = tte+i;
|
||||||
}
|
}
|
||||||
*replace = TTEntry(pos.get_key(), v, type, d, m, generation);
|
*replace = TTEntry(pos.get_key(), v, type, d, m, generation);
|
||||||
|
|
Loading…
Add table
Reference in a new issue