lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>but how exactly does this work?  I can certainly see the use of a hash
>function to do a fast first-level lookup, but once you find a match on
>the hash, don't you then need to do a standard string compare on what
>you found to ensure the hash is for that value?  If not, how are hash
>collisions handled?

Lua keeps only 1 copy of each string. So, only pointer comparisons are
needed to compare strings. All string processing is done when the string
is "interned" into Lua. From then on, pointers are enough for some uses;
for adding a field to a table, a hash is needed, but it is done based on
the hash value computed at intern time.
--lhf