[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua in high performance apps
- From: Steve Dekorte <steve@...>
- Date: Wed, 2 May 2001 13:42:05 -0700
Joshua Jensen wrote:
1) Local variables are very quick, since they are accessed by index. If
possible, make global variables local (weird, eh?)...
This technique can also be used for functions...
I just got around to playing with this and it works great.
For example this code:
local i, v = next(t, nil)
while i do i, v = next(t, i) end
Is 10% faster if you make "next" a local:
local next = next
local i, v = next(t, nil)
while i do i, v = next(t, i) end
I also did some other tests and found that foreach() is ~20% faster than
the equivalent while loop, while foreachi() was ~20% slower than a while
loop.
Steve