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:
> >I'm not saying it's a bad thing that Lua is memory efficient; I am
> >merely trying to determine if this is something which will eat CPU in my
> >case.
> 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).

Sounding good...

> 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.

Aah, I get it ;-)

I was hoping it'd be something cunning, and that is cunning ;-)

Sounds excellent.

Thank you for that clarification.

D.

-- 
Daniel Silverstone                               http://www.digital-scurf.org/
Hostmaster, Webmaster, and Chief Code Wibbler          Digital-Scurf Unlimited
GPG Public key available from keyring.debian.org               KeyId: 20687895
You look tired.