lua-users home
lua-l archive

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


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

I don't think so. The table is quite small: Typically around log2 of the
length of the final string, so for a string of 1M you will need only
20 entries. The strings inside it are parts of the final string, so
they use the same space that a buffer would use (but broken in several
parts).

> and when closing it, we still have to concatenate the parts, 
> generating garbage to collect.

That is true... But it is difficult to anticipate that this will be a
real problem in real applications. (And, in Lua 5, we can use
table.concat to close it more efficiently.)

-- Roberto