Handle empty string map keys.
This commit is contained in:
+7
-4
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user