Short strings always use all bytes in the hash

Collisions in short strings occurr just by their existence, when
internalizing them. (Collisions in long strings is caused/controlled
by the program, when adding them as keys to the same table.)
This commit is contained in:
Roberto Ierusalimschy
2020-04-01 10:52:41 -03:00
parent 513559cc47
commit 7288528a1e
3 changed files with 10 additions and 7 deletions

View File

@@ -76,7 +76,7 @@ static unsigned int luai_makeseed (lua_State *L) {
addbuff(buff, p, &h); /* local variable */
addbuff(buff, p, &lua_newstate); /* public function */
lua_assert(p == sizeof(buff));
return luaS_hash(buff, p, h);
return luaS_hash(buff, p, h, 1);
}
#endif