[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Shorthand for appending to a table (was Re: 5.2 feature list?)
- From: roberto@... (Roberto Ierusalimschy)
- Date: Tue, 12 Sep 2006 09:57:06 -0300
> Seriously though, my attatchment to the feature idea is not strong;
> it would just be a convenience. We do have code where the performance
> difference is meaningful, but that's *not* the majority of places
> where we append items, so I suppose we'll have to live with the more
> cumbersome syntax reallyLongName[ #reallyLongName + 1 ] = v where we
> need the speed.
When you really need the speed, you should consider the use of an
explicit counter inside the inner loop:
i = i + 1
aVeryVeryLongNameWrittenOnlyOnce[i] = new value
This is still faster than "a[#a+1]" (and avoids the original problem).