From: mstembera Date: Sun, 23 Dec 2018 15:10:07 +0000 (-0800) Subject: Use a bit less code to calculate hashfull() (#1830) X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=656aad8b0c10f43eae7744edc1b7171720ac7426 Use a bit less code to calculate hashfull() (#1830) * Use a bit less code to calculate hashfull(). Change post increment to preincrement as is more standard in the rest of stockfish. Scale result so we report 100% instead of 99.9% when completely full. No functional change. --- diff --git a/src/tt.cpp b/src/tt.cpp index 50e8a3bf..653d081f 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -85,7 +85,7 @@ void TranspositionTable::clear() { std::vector threads; - for (size_t idx = 0; idx < Options["Threads"]; idx++) + for (size_t idx = 0; idx < Options["Threads"]; ++idx) { threads.emplace_back([this, idx]() { @@ -148,12 +148,9 @@ TTEntry* TranspositionTable::probe(const Key key, bool& found) const { int TranspositionTable::hashfull() const { int cnt = 0; - for (int i = 0; i < 1000 / ClusterSize; i++) - { - const TTEntry* tte = &table[i].entry[0]; - for (int j = 0; j < ClusterSize; j++) - if ((tte[j].genBound8 & 0xFC) == generation8) - cnt++; - } - return cnt; + for (int i = 0; i < 1000 / ClusterSize; ++i) + for (int j = 0; j < ClusterSize; ++j) + cnt += (table[i].entry[j].genBound8 & 0xFC) == generation8; + + return cnt * 1000 / (ClusterSize * (1000 / ClusterSize)); }