lua-users home
lua-l archive

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

luaV_concat() uses the more general realloc interface, instead of a
free/malloc, when growing a short buffer for string concatenation.
doesn't this result in unnecessary memory copies (since we don't
need the buffer's old contents) ?

i replaced

        buffer = luaZ_openspace(L, &G(L)->buff, tl);


        #include "lmem.h"

        if (tl > G(L)->buff.buffsize) {
          luaM_free(L, G(L)->buff.buffer, G(L)->buff.buffsize);
          G(L)->buff.buffer = luaM_malloc(L, tl);
        buffer = G(L)->buff.buffer;

and did a quick valgrind cache profile to confirm this (otoh, the
savings weren't very spectacular).