Re: Max length of string keys in hash tables
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Max length of string keys in hash tables
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: 2010年4月30日 15:44:07 -0300
> In _The implementation of Lua 5.0_, it says "The hash function does not look at all bytes of the string if the string is too long."
>
> What is n such that strings that differ only from index n+1 will be evaluated as the same by Lua?
That's not how it works. For strings of length less than 32, all bytes
are visited. For longer strings, only every k bytes are visited, where
k = (l>>5)+1 and is the length. See luaS_newlstr in
http://www.lua.org/source/5.1/lstring.c.html