diff options
author | Matthew Wild <mwild1@gmail.com> | 2008-12-05 00:25:41 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2008-12-05 00:25:41 +0000 |
commit | 1889d09bcc236c0e8f8e7a779b0ea939af5e7309 (patch) | |
tree | f03b67439bab8d5595ea2f63ca66153334f333fa /util/multitable.lua | |
parent | c37c7b486b3c61540f77310ece7273582c70ffd6 (diff) | |
parent | bd000cf50917ec7570bf70eeda38c259e70a923e (diff) | |
download | prosody-1889d09bcc236c0e8f8e7a779b0ea939af5e7309.tar.gz prosody-1889d09bcc236c0e8f8e7a779b0ea939af5e7309.zip |
Merge from waqas
Diffstat (limited to 'util/multitable.lua')
-rw-r--r-- | util/multitable.lua | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/util/multitable.lua b/util/multitable.lua index f586330e..a3bfe946 100644 --- a/util/multitable.lua +++ b/util/multitable.lua @@ -22,6 +22,7 @@ local select = select; local t_insert = table.insert; local pairs = pairs; +local next = next; module "multitable" @@ -55,10 +56,19 @@ local function r(t, n, _end, ...) end local k = select(n, ...); if k then - r(t[k], n+1, _end, ...); + v = t[k]; + if v then + r(v, n+1, _end, ...); + if not next(v) then + t[k] = nil; + end + end else for _,b in pairs(t) do r(b, n+1, _end, ...); + if not next(b) then + t[_] = nil; + end end end end |