- tte = replace = first_entry(pos);
- for (int i = 0; i < 4; i++, tte++)
- {
- if (!tte->key()) // still empty
- {
- *tte = TTEntry(pos.get_key(), v, type, d, m, generation);
- writes++;
- return;
- }
- else if (tte->key() == pos.get_key()) // overwrite old
- {
- if (m == MOVE_NONE)
- m = tte->move();
-
- *tte = TTEntry(pos.get_key(), v, type, d, m, generation);
- return;
- }
- else if (i == 0) // replace would be a no-op in this common case
- continue;
-
- int c1 = (replace->generation() == generation ? 2 : 0);
- int c2 = (tte->generation() == generation ? -2 : 0);
- int c3 = (tte->depth() < replace->depth() ? 1 : 0);
-
- if (c1 + c2 + c3 > 0)
- replace = tte;
- }
- *replace = TTEntry(pos.get_key(), v, type, d, m, generation);
- writes++;
-}
+ TTEntry* const tte = first_entry(key);
+ const uint16_t key16 = key >> 48; // Use the high 16 bits as key inside the cluster