From 15758d448dfce7c797f48fc0284fa670cae803f1 Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Fri, 24 Feb 2023 10:45:33 -0500 Subject: [PATCH] Pre-size scores in find_perfect_hash_seed This improves startup of a small Python file by 1.35% (instruction count from Callgrind) for me. --- src/namedict.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/namedict.h b/src/namedict.h index ed6da0f2..511dd042 100644 --- a/src/namedict.h +++ b/src/namedict.h @@ -52,7 +52,7 @@ namespace pkpy{ uint32_t find_perfect_hash_seed(uint32_t capacity, const std::vector& keys){ if(keys.empty()) return kHashSeeds[0]; std::set indices; - std::vector> scores; + std::vector> scores(kHashSeeds.size()); for(int i=0; i b.second; }); return scores[0].first;