浏览代码

Fixed reloadpcdb (#7065)

Fixes #7063

Thanks to @kaninhot004
Lemongrass3110 2 年之前
父节点
当前提交
17d6381901
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      src/common/database.hpp

+ 3 - 1
src/common/database.hpp

@@ -183,8 +183,10 @@ public:
 
 			// Check if the key fits into the current cache size
 			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
-				size_t new_size = key * 2;
+				size_t new_size = std::max( key, minimum ) * 2;
 
 				// Very important => initialize everything to nullptr
 				this->cache.resize(new_size, nullptr);