lua-users home
lua-l archive

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


On Thu, May 08, 2003 at 08:40:54AM -0300, Luiz Henrique de Figueiredo wrote:
> 
> Like everything else in Lua, strings are kept in a hash table. They are
> only hashed once, when they cross the C/Lua boundary (eg, in lua_pushstring
> or internally when the VM concatenates strings). Once in Lua, no more string
> hashing is needed. Like I said, string comparison becomes pointer comparison
> and strings become as fast as any other value (all comparisons are in effect
> pointer comparisons, except for numbers, booleans, and nil).
> 
> The memory overhead for strings is simply its hash value, which is an int.
> The time overhead is deciding whether a string is already in the string table
> and, if not, to add it. This is as hash table and thus should be fast, as fast
> as (actually faster than) table lookup, on which everything in Lua is based.
>

icon's string allocation strategy, described in

    http://www.cs.arizona.edu/icon/docs/ipd277.htm

seems to argue against string interning.  not sure how relevant that strategy
is to lua though (different domains, different tradeoffs ???)

-taj