summaryrefslogtreecommitdiff
path: root/src/mongo/util/string_map.h
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2015-09-04 19:28:39 -0400
committerMathias Stearn <mathias@10gen.com>2015-09-25 18:09:33 -0400
commit369164318a5e0c952f3de426a68c48078c64c60c (patch)
tree7c4d4e8b4094b956bc70025c192ff6ea0158844a /src/mongo/util/string_map.h
parentbb235f80e2b9fe431176e0983a6a16aea7674541 (diff)
downloadmongo-369164318a5e0c952f3de426a68c48078c64c60c.tar.gz
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
Diffstat (limited to 'src/mongo/util/string_map.h')
-rw-r--r--src/mongo/util/string_map.h10
1 files changed, 9 insertions, 1 deletions
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 <third_party/murmurhash3/MurmurHash3.h>
+
#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 {