Microptimize first_entry() for 32bits

Do a 32bit bitwise 'and' instead of a 64bit
subtract and bitwise 'and'.

This is possible because even in the biggest
hash table case (8GB) the number of entries
is 2^29 so storable in an unsigned int.

No functional change.
This commit is contained in:
Marco Costalba
2013-02-09 10:22:34 +01:00
parent fe3352665b
commit c698362680
2 changed files with 8 additions and 6 deletions

View File

@@ -32,12 +32,14 @@ TranspositionTable TT; // Our global transposition table
void TranspositionTable::set_size(size_t mbSize) {
size_t newSize = 1ULL << msb((mbSize << 20) / sizeof(TTEntry[ClusterSize]));
assert(msb((mbSize << 20) / sizeof(TTEntry)) < 32);
if (newSize == size)
uint32_t size = 1 << msb((mbSize << 20) / sizeof(TTEntry[ClusterSize]));
if (clusterMask == size - 1)
return;
size = newSize;
clusterMask = size - 1;
delete [] entries;
entries = new (std::nothrow) TTEntry[size * ClusterSize];
@@ -58,7 +60,7 @@ void TranspositionTable::set_size(size_t mbSize) {
void TranspositionTable::clear() {
memset(entries, 0, size * sizeof(TTEntry[ClusterSize]));
memset(entries, 0, (clusterMask + 1) * sizeof(TTEntry[ClusterSize]));
}