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;
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
#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
};