mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 15:39:33 +00:00
Fixes field 'empty' is not callable (a nil value)
Partially addresses #5965
This commit is contained in:
parent
913d39c159
commit
5502f3fc2e
3 changed files with 28 additions and 23 deletions
|
|
@ -105,6 +105,33 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
-- NOTE: on index based tables using #table is much more performant
|
||||
function table.len(tbl)
|
||||
local count = 0
|
||||
|
||||
if(tbl == nil) then return(0) end
|
||||
|
||||
for k,v in pairs(tbl) do
|
||||
count = count + 1
|
||||
end
|
||||
|
||||
return count
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function table.slice(tbl, first, last, step)
|
||||
local sliced = {}
|
||||
|
||||
for i = first or 1, last or #tbl, step or 1 do
|
||||
sliced[#sliced+1] = tbl[i]
|
||||
end
|
||||
|
||||
return sliced
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function table.empty(tbl)
|
||||
if(tbl == nil) then return true end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue