lua-users home
lua-l archive

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


Hi Gé:

On Sat, 23 Jul 2022 at 00:54, Gé Weijers <ge@weijers.org> wrote:
> On Fri, Jul 22, 2022 at 2:30 AM Francisco Olarte <folarte@peoplecall.com> wrote:
>> Not the OP, but I think what he is trying to point is simple tricks
...
> That's it exactly, and if you try to avoid this issue by caching the values you use to calculate the string size you could end up with even worse behavior. There's no silver bullet here that solves the problem for all possible use cases.

Never is. OTOH my look at tconcat seemed to point you can, which some
minimal, may be a page, hacking build a concatlen function plus a
concatx one which has an initial buffer size which, on the simple
case, would avoid reallocations while being as safe as the original on
things like your example ( they will give different results, but if
someone makes a table like yours he is prepared for that, in fact I
think table.concat will do it for tewo consecutive runs over it ). Not
going  to propose it anyway, as I feel this belongs in a module if
someone needs it, I do not consider stock lua an apropiate tool for
huge texts manips, but I have too many tools to choose from ).

Francisco Olarte.