lua-users home
lua-l archive

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


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