parent
5e6fd03848
commit
17d6381901
@ -183,8 +183,10 @@ public:
|
|||||||
|
|
||||||
// Check if the key fits into the current cache size
|
// Check if the key fits into the current cache size
|
||||||
if (this->cache.capacity() <= key) {
|
if (this->cache.capacity() <= key) {
|
||||||
|
// Some keys compute to 0, so we allocate a minimum of 500 (250*2) entries
|
||||||
|
const static size_t minimum = 250;
|
||||||
// Double the current size, so we do not have to resize that often
|
// Double the current size, so we do not have to resize that often
|
||||||
size_t new_size = key * 2;
|
size_t new_size = std::max( key, minimum ) * 2;
|
||||||
|
|
||||||
// Very important => initialize everything to nullptr
|
// Very important => initialize everything to nullptr
|
||||||
this->cache.resize(new_size, nullptr);
|
this->cache.resize(new_size, nullptr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user