From 369164318a5e0c952f3de426a68c48078c64c60c Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Fri, 4 Sep 2015 19:28:39 -0400 Subject: SERVER-20300 Optimize StringMap Major changes: * Use 32-bit murmur3 rather than 128-bit * Use bit-masks rather than modulus * Default-constructed StringMaps don't allocate memory * Can no longer configure max probe ratio or default starting size --- src/mongo/util/string_map.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/mongo/util/string_map.h') diff --git a/src/mongo/util/string_map.h b/src/mongo/util/string_map.h index 13e93977fcc..ff2946a8f95 100644 --- a/src/mongo/util/string_map.h +++ b/src/mongo/util/string_map.h @@ -29,12 +29,20 @@ #pragma once +#include + #include "mongo/base/string_data.h" #include "mongo/util/unordered_fast_key_table.h" namespace mongo { -typedef StringData::Hasher StringMapDefaultHash; +struct StringMapDefaultHash { + uint32_t operator()(StringData a) const { + uint32_t hash; + MurmurHash3_x86_32(a.rawData(), a.size(), 0, &hash); + return hash; + } +}; struct StringMapDefaultEqual { bool operator()(StringData a, StringData b) const { -- cgit v1.2.1