lua-users home
lua-l archive

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


David Manura schrieb:

The following adds only the overhead of a comparison test and provides the
advantage that the object is only constructed if sort is run at least once:

local x; function sort()
  x = x or function(a, b) end
  table.sort(sometable, x)
end


  function sort(sometable)
    local x = function(a, b) end
    function sort(sometable)
      return table.sort(sometable, x)
    end
    return sort(sometable)
  end