19 #ifndef PAGESPEED_KERNEL_BASE_STRING_HASH_H_
20 #define PAGESPEED_KERNEL_BASE_STRING_HASH_H_
27 namespace net_instaweb {
31 template<
class CharTransform,
typename IntType>
36 for (
const char* end = s + len; s != end; ++s) {
37 result = (result * 131) + CharTransform::Normalize(*s);
45 return (a + 56) * 137 + b * 151;
61 static bool Compare(
const StringPiece& a,
const StringPiece& b) {
68 static unsigned char Normalize(
char c) {
72 static bool Compare(
const StringPiece& a,
const StringPiece& b) {
80 return HashString<CasePreserve, size_t>(str.data(), str.size());
86 return HashString<CaseFold, size_t>(str.data(), str.size());
92 return MemCaseEqual(a.data(), a.size(), b.data(), b.size());
97 size_t operator()(StringPiece str)
const {
98 return HashString<CasePreserve, size_t>(str.data(), str.size());
103 size_t operator()(StringPiece str)
const {
104 return HashString<CaseFold, size_t>(str.data(), str.size());
108 bool operator()(StringPiece a, StringPiece b)
const {
109 return MemCaseEqual(a.data(), a.size(), b.data(), b.size());
size_t JoinHash(size_t a, size_t b)
Definition: string_hash.h:44
Definition: string_hash.h:84
char LowerChar(char c)
Definition: string_util.h:544
Functors for constructing case-insensitive and case-sensitive hash-tables.
Definition: string_hash.h:78
bool MemCaseEqual(const char *s1, size_t size1, const char *s2, size_t size2)
Return true iff the two strings are equal, ignoring case.
Definition: string_hash.h:96
A helper for case-sensitive hashing.
Definition: string_hash.h:49
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
Definition: string_hash.h:102
IntType HashString(const char *s, size_t len)
Definition: string_hash.h:32
int StringCaseCompare(StringPiece s1, StringPiece s2)
Case-insensitive string comparison that is locale-independent.
Definition: string_hash.h:107
Definition: string_hash.h:90
A helper for case-insensitive hashing, which folds to lowercase.
Definition: string_hash.h:67
static unsigned char Normalize(char c)
Definition: string_hash.h:57