]> git.sesse.net Git - stockfish/commitdiff
Small tidyup of TranspositionTable::store()
authorMarco Costalba <mcostalba@gmail.com>
Mon, 10 Nov 2008 14:26:57 +0000 (15:26 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 10 Nov 2008 18:19:40 +0000 (19:19 +0100)
Hopefully without bugs this time!

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/tt.cpp

index fb524e303fa3a932be953775c03a64e410c4b39a..e9d8d7546f77a3d06ae0beb22c3bfc35892c1522 100644 (file)
@@ -108,31 +108,31 @@ void TranspositionTable::store(const Position &pos, Value v, Depth d,
   TTEntry *tte, *replace;
 
   tte = replace = first_entry(pos);
   TTEntry *tte, *replace;
 
   tte = replace = first_entry(pos);
-  for (int i = 0; i < 4; i++)
+  for (int i = 0; i < 4; i++, tte++)
   {
   {
-    if (!(tte+i)->key()) // still empty
+    if (!tte->key()) // still empty
     {
     {
-        *(tte+i) = TTEntry(pos.get_key(), v, type, d, m, generation);
+        *tte = TTEntry(pos.get_key(), v, type, d, m, generation);
         writes++;
         return;
     }
         writes++;
         return;
     }
-    if ((tte+i)->key() == pos.get_key()) // overwrite old
+    else if (tte->key() == pos.get_key()) // overwrite old
     {
         if (m == MOVE_NONE)
     {
         if (m == MOVE_NONE)
-            m = (tte+i)->move();
+            m = tte->move();
 
 
-        *(tte+i) = TTEntry(pos.get_key(), v, type, d, m, generation);
+        *tte = TTEntry(pos.get_key(), v, type, d, m, generation);
         return;
     }
         return;
     }
-    if (i == 0)  // replace would be a no-op in this common case
+    else if (i == 0)  // replace would be a no-op in this common case
         continue;
 
     int c1 = (replace->generation() == generation ?  2 : 0);
         continue;
 
     int c1 = (replace->generation() == generation ?  2 : 0);
-    int c2 = ((tte+i)->generation() == generation ? -2 : 0);
-    int c3 = ((tte+i)->depth() < replace->depth() ?  1 : 0);
+    int c2 = (tte->generation() == generation ? -2 : 0);
+    int c3 = (tte->depth() < replace->depth() ?  1 : 0);
 
     if (c1 + c2 + c3 > 0)
 
     if (c1 + c2 + c3 > 0)
-        replace = tte+i;
+        replace = tte;
   }
   *replace = TTEntry(pos.get_key(), v, type, d, m, generation);
   writes++;
   }
   *replace = TTEntry(pos.get_key(), v, type, d, m, generation);
   writes++;