lua-users home
lua-l archive

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


It was thus said that the Great John Hind once stated:
> 
> 3. Multiple inserts (and more spectacularly, removes) are a clear
> opportunity for performance optimisation, but it is easy to do this in
> Lua. Having the library functions just encourages inefficient coding.

  I don't follow.  Sure, 

	t[#t+1] = v

and

	table.insert(t,v)

are the same, but 

	table.insert(t,1,v)

might perform better as is than a pure Lua solution (for sufficiently large
values of N, where N = #t).  Okay, I haven't measured that, but that would
be my gut feeling.

  So, aside from a performance optimization, yes, it can all be done in pure
Lua.  But I also don't follow your "encourages inefficient coding' logic
here.

  -spc (The rest of your post---I either agreed with, or don't have an
	opinion on ... )