lua-users home
lua-l archive

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


On Thu, Mar 27, 2014 at 4:22 AM, Peter Melnichenko
<petjamelnik@yandex.ru> wrote:
> Tim Hill wrote:
>>  It already does. In fact it uses a rather clean algorithm to perform a pretty optimal number of allocations/copies during the concatenation. See PiL for more information.
>
> IIRC starting from Lua 5.2 luaL_Buffer(used internally by table.concat) is a simple buffer, doubling in size when it overflows, and not the "Tower of Hanoi" described in PiL.
>
> Peter
>

I believe std::string's in C++ allocate in the same way, also
std::vector's.  The Tower of Hanoi concatenating thing is useful for
keeping memory down to the sqrt() of the n-many strings you will have
to concatenate (iirc).