lua-users home
lua-l archive

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


On 2002/10/22 18:45:19, Roberto Ierusalimschy <roberto@inf.puc-rio.br> 
wrote:

>> Perhaps Lua 5 might need string buffers (growable buffer of
>> characters), so that string manipulation becomes more efficient. I
>> read somewhere (but forgot the URL) that Lua performs very well (w.r.t
>> other scripting languages) except for string manipulation. But I may
>> be wrong!
> 
> It is quite easy to implement a string buffer in Lua itself; see 
> http://www.bagley.org/~doug/shootout/bench/strcat/strcat.lua

Interesting, it seems to be an implementation of the LTN9 
<http://www.lua.org/notes/ltn009.html>.
But I think Basile meant "efficient string buffers"...

Your implementation is good, of course, but still seems (if I understood 
the algorithm) to suffer (to a lesser extent) of some of the old problems: 
it is quite memory intensive as it uses a table to store parts of the 
buffer, and when closing it, we still have to concatenate the parts, 
generating garbage to collect.

Now, a string buffer library can be written quite easily and efficiently. 
The hard part may be to allow smooth integration with native strings. Or 
not?

-- 
--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--
Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist
http://jove.prohosting.com/~philho/