[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table.n
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 02 Apr 2001 10:14:09 -0300
As Steve pointed out, the '.n' avoids the recalculation of the 'size' of
an array each time getn is called. Actually, you should avoid using it
directly; instead, use `getn'. But `getn' is much faster when '.n' is
present (it goes from O(n) to O(1)). In a loop like
a = {}
while 1 do
local line = read()
if not line then break end
tinsert(a, line)
end
it makes a huge difference.
-- Roberto