On 2010-12-18 <14:20:46>, Hans Hagen wrote: > On 18-12-2010 2:06, Philipp Gesang wrote: > > >What always baffled me is that in the manual Roberto advertises > >ipairs() as the iterator of choice (at least in the v.5.0 doc). > >Compared to the other options using it is just, well, erratic. > > I did lots of testing (an doptimizing) in critical code but in > practice one will not notice much difference in a mkiv run. > Actually, I changed all pairs, ipairs as there was a temporary > intention to remove them from the lua core. > > btw, in for i=1,#t do ... the #t is also a function call (so having
My fault, I just forgot about that; with the array size stored in a local variable the “for” loop is faster than “while”, as expected. > many in these t[#t+1] = ... cases is also slower but again, seldom > noticeable as lua in general is so fast … when adding to an array the “t[#t+1] = elm” approach turns out to be still faster than table.insert() which, again, is advertised in the manual. Even python’s append() method is faster than table.insert() and that means a lot. Philipp -- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments
pgpRKP0XVVcs3.pgp
Description: PGP signature
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________