summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-01-09 21:30:18 (GMT)
committerEvan Martin <martine@danga.com>2012-01-09 21:30:18 (GMT)
commita844fba695d4a62d4ae5bf98c6df3b0677df18b2 (patch)
treeabe431ab685c167af82a6693f30c430da32154d8 /src
parentfc36ba5f04f659f485e4ae9d70ad826b5838959d (diff)
downloadNinja-a844fba695d4a62d4ae5bf98c6df3b0677df18b2.zip
Ninja-a844fba695d4a62d4ae5bf98c6df3b0677df18b2.tar.gz
Ninja-a844fba695d4a62d4ae5bf98c6df3b0677df18b2.tar.bz2
murmur -> stl hash
Diffstat (limited to 'src')
-rw-r--r--src/hash_map.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/hash_map.h b/src/hash_map.h
index 0aac7d6..7cbd052 100644
--- a/src/hash_map.h
+++ b/src/hash_map.h
@@ -52,6 +52,15 @@ unsigned int MurmurHash2(const void* key, int len, unsigned int seed) {
return h;
}
+static size_t StlHash(StringPiece str) {
+ const char* p = str.str_;
+ int len = str.len_;
+ size_t hash = 0;
+ while (len--)
+ hash = 5 * hash + *p++;
+ return hash;
+}
+
#ifdef _MSC_VER
#include <hash_map>
@@ -83,7 +92,7 @@ struct hash<std::string> {
/// Hash functor for StringPiece.
struct ExternalStringHash {
size_t operator()(StringPiece key) const {
- return MurmurHash2(key.str_, key.len_, kSeed);
+ return StlHash(key);
}
};
#endif