lua-users home
lua-l archive

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


On Thu, Mar 27, 2014 at 1:57 PM, Coroutines <coroutines@gmail.com> wrote:
> 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).


AFAIR, the PiL contatenation algorithm was intended to reduce the
number of string internings, not allocations.  once you do it in C,
you don't have to intern anything until the end.  in the
table.concat() case, it's possible to allocate just once, since the
final size is easily knowable.

-- 
Javier