lua-users home
lua-l archive

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

On Mar 27, 2014, at 12:56 PM, Coroutines <> wrote:

> I was making a point that sometimes large realloc()'s to truly move
> strings together in memory (concatenation) can be bad :>  Seems like
> for the usual small string the complexity and potential for cache
> misses are worse, though.

Agreed. It will, of course, temporarily need N*2 bytes of space for a final string length of N bytes. The nice thing about the PiL algorithm is that, since input strings can be discarded as the “tower” is built, the maximum memory consumed *during* concat can be significantly less.