Dict: use std::log2, remove custom Log2 method

This commit is contained in:
Tim Wojtulewicz 2022-08-31 20:44:50 +00:00 committed by Tim Wojtulewicz
parent 7e65b285ea
commit 25a280d6a1

View file

@ -3,6 +3,7 @@
#pragma once #pragma once
#include <algorithm> #include <algorithm>
#include <cmath>
#include <cstdint> #include <cstdint>
#include <fstream> #include <fstream>
#include <memory> #include <memory>
@ -456,7 +457,7 @@ public:
{ {
// If an initial size is speicified, init the table right away. Otherwise wait until the // If an initial size is speicified, init the table right away. Otherwise wait until the
// first insertion to init. // first insertion to init.
log2_buckets = Log2(initial_size); log2_buckets = static_cast<unsigned char>(std::log2(initial_size));
Init(); Init();
} }
@ -941,14 +942,6 @@ private:
} }
// bucket math // bucket math
int Log2(int num) const
{
int i = 0;
while ( num >>= 1 )
i++;
return i;
}
int ThresholdEntries() const int ThresholdEntries() const
{ {
// Increase the size of the dictionary when it is 75% full. However, when the dictionary // Increase the size of the dictionary when it is 75% full. However, when the dictionary