lua-users home
lua-l archive

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

Paul Sheer <> wrote:
> It's faster by a factor of 30 than addString
> of section 11.6 of PIL

I could be reading it wrong, but it looks to me like
addString is there for illustration purposes, to show
the algorithm used INTERNALLY be table.concat and a
few other library functions.

> local n = 1
> local s = "hellothere"
> while n < 50000 do
>    s = string.append(s, "a")
>    n = n + 1
> end

BTW: Lua has a numerical for loop, so you could have written that:

   local s = "hellothere"
   for n=1,50000 do
      s = string.append(s, "a")

Have you compared it's performance with:

   local buf = { "hellothere" }
   for n=2,50000 do
      buf[n] = "a"
   local s = table.concat(buf)