This commit is contained in:
Phil Race 2018-05-16 09:45:40 -07:00
commit 7984fb2956
1140 changed files with 122023 additions and 3832 deletions

View file

@ -57,14 +57,16 @@ const char FileSeparator = '/';
// Compute the Perfect Hashing hash code for the supplied UTF-8 string.
s4 ImageStrings::hash_code(const char* string, s4 seed) {
assert(seed > 0 && "invariant");
// Access bytes as unsigned.
u1* bytes = (u1*)string;
u4 useed = (u4)seed;
// Compute hash code.
for (u1 byte = *bytes++; byte; byte = *bytes++) {
seed = (seed * HASH_MULTIPLIER) ^ byte;
useed = (useed * HASH_MULTIPLIER) ^ byte;
}
// Ensure the result is not signed.
return seed & 0x7FFFFFFF;
return (s4)(useed & 0x7FFFFFFF);
}
// Match up a string in a perfect hash table.