Handle empty string map keys.

This commit is contained in:
Bob Nystrom
2015-03-17 07:00:54 -07:00
parent 91a23da5b0
commit b4fa4acce1
2 changed files with 12 additions and 4 deletions
+7 -4
View File
@@ -368,11 +368,14 @@ static uint32_t hashObject(Obj* object)
// towards the prefix or suffix of the string. So sample up to eight
// characters spread throughout the string.
// TODO: Tune this.
uint32_t step = 1 + 7 / string->length;
for (uint32_t i = 0; i < string->length; i += step)
if (string->length > 0)
{
hash ^= string->value[i];
hash *= 16777619;
uint32_t step = 1 + 7 / string->length;
for (uint32_t i = 0; i < string->length; i += step)
{
hash ^= string->value[i];
hash *= 16777619;
}
}
return hash;