lua-users home
lua-l archive

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


On Thu, 21 Jul 2022 at 22:43, ubq323 <ubq323@ubq323.website> wrote:
> i wonder, what if table.concat could take an additional argument, to be used as
> a hint for how big its buffer should be allocated?
> obviously this wouldn't be without problems either, it's just a thought i had
> right now.

Writing an alternate version is easy, as is adding it. a copule dozen
lines patch to ltablib.c will do it. Once done probably a concatlen
method would be useful ( doing more or less the same as concat but
without storing anything ) so on uber-thight situations you can hint
it with the exact len at the cost of an extra pass ( disregarding
degenerate code as the one Gé ilustrated, but that would work ok, but
with reallocations, but any competent programmer can make library code
misbehave.

Francisco Olarte.