lua-users home
lua-l archive

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

On Mar 27, 2014, at 1:30 AM, Oliver Kroth <> wrote:

> It would use one single buffer, possibly with precomputed sufficient size (if, e.g. all operands are strings).
> The .. operators use a buffer each plus the memory for the (intermediate) result strings.
> So string.concat() could save memory allocation operations and the multiple copy operations from one buffer into the next.
> At least this is my understanding, correct me if I am wrong...
> — Oliver

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.