[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: lstring expansion from the c side
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Wed, 31 May 2000 21:15:19 -0300 (EST)
>From lua-l@tecgraf.puc-rio.br Wed May 31 18:54:33 2000
>From: Jim Mathies <Jim@mathies.com>
>
>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
strings.
If you need to expand strings and need not compare them in Lua, you might
try using a userdata pointing to it.
--lhf