]> git.sesse.net Git - stockfish/commitdiff
Use a bit less code to calculate hashfull() (#1830)
authormstembera <m_stembera@yahoo.com>
Sun, 23 Dec 2018 15:10:07 +0000 (07:10 -0800)
committerMarco Costalba <mcostalba@users.noreply.github.com>
Sun, 23 Dec 2018 15:10:07 +0000 (16:10 +0100)
* 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.

src/tt.cpp

index 50e8a3bfac4bad1bcf72ee61d79664d2db36fbe8..653d081f8f0eb01859408043467a4e0486241f2f 100644 (file)
@@ -85,7 +85,7 @@ void TranspositionTable::clear() {
 
   std::vector<std::thread> threads;
 
 
   std::vector<std::thread> threads;
 
-  for (size_t idx = 0; idx < Options["Threads"]; idx++)
+  for (size_t idx = 0; idx < Options["Threads"]; ++idx)
   {
       threads.emplace_back([this, 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;
 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));
 }
 }