diff --git a/src/namedict.h b/src/namedict.h index 511dd042..193a064b 100644 --- a/src/namedict.h +++ b/src/namedict.h @@ -52,7 +52,8 @@ 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(kHashSeeds.size()); + uint32_t best_seed = 0; + float best_score = std::numeric_limits::max(); for(int i=0; i best_score) { + best_score = score; + best_seed = kHashSeeds[i]; + } } - std::sort(scores.begin(), scores.end(), [](auto a, auto b){ return a.second > b.second; }); - return scores[0].first; + return best_seed; } struct NameDict {