lua-users home
lua-l archive

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

>From  Wed May 31 18:54:33 2000
>From: Jim Mathies <>
>My biggest concern here is being fast, I'd rather
>not invoke any tag methods or have to create new strings
>or anything.

The creation of new strings does not involve any tag methods.

>I'd just like a simple:
>lua_expandlstring( lo, newbuffersize )
>.so I can get the lstr buffer pointer and copy new (sometimes
>larger) data chunks into it.

However, you cannot "reuse" existing strings and need to create new strings 
because strings are kept in a hash table: if the contents of the string changes,
then its hash value must be recomputed.

Having strings kept in a hash table is very nice because it allows the
comparison of strings in Lua in constant time (we just compare pointers,
because no string occurs twice in Lua), but it does have a cost when creating

If you need to expand strings and need not compare them in Lua, you might
try using a userdata pointing to it.