summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-01-09 22:06:09 (GMT)
committerEvan Martin <martine@danga.com>2012-01-09 22:06:19 (GMT)
commite8610adb68fe7ec45c158ce970cb37e1d88e750b (patch)
tree193007ea41b1a19d0546ffa3ef1a60e763457b92
parent7fdd3fb10d2527c93635d6a1fb72c32d25ab04e6 (diff)
downloadNinja-e8610adb68fe7ec45c158ce970cb37e1d88e750b.zip
Ninja-e8610adb68fe7ec45c158ce970cb37e1d88e750b.tar.gz
Ninja-e8610adb68fe7ec45c158ce970cb37e1d88e750b.tar.bz2
back to murmur hash
-rw-r--r--src/hash_map.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/hash_map.h b/src/hash_map.h
index 3ad4d73..dc08d61 100644
--- a/src/hash_map.h
+++ b/src/hash_map.h
@@ -52,7 +52,7 @@ unsigned int MurmurHash2(const void* key, int len, unsigned int seed) {
return h;
}
-static size_t StlHash(StringPiece str) {
+static inline size_t StlHash(StringPiece str) {
const char* p = str.str_;
int len = str.len_;
size_t hash = 0;
@@ -86,15 +86,15 @@ struct hash<std::string> {
return hash<const char*>()(s.c_str());
}
};
-}
-
-/// Hash functor for StringPiece.
-struct ExternalStringHash {
+template<>
+struct hash<StringPiece> {
size_t operator()(StringPiece key) const {
- return StlHash(key);
+ return MurmurHash2(key.str_, key.len_, kSeed);
}
};
+
+}
#endif
/// A template for hash_maps keyed by a StringPiece whose string is
@@ -106,7 +106,7 @@ struct ExternalStringHashMap {
#ifdef _MSC_VER
typedef hash_map<const char*, V, hash_compare<const char *,ExternalStringCmp> > Type;
#else
- typedef hash_map<StringPiece, V, ExternalStringHash> Type;
+ typedef hash_map<StringPiece, V> Type;
#endif
};