mirror of
https://github.com/airstruck/luigi.git
synced 2025-12-19 02:16:43 +00:00
decouple icon from text, see #19
This commit is contained in:
32
luigi/cleaner.lua
Normal file
32
luigi/cleaner.lua
Normal file
@@ -0,0 +1,32 @@
|
||||
local Cleaner = {}
|
||||
|
||||
local marked = {}
|
||||
local watched = setmetatable({}, { __mode = 'k' })
|
||||
|
||||
function Cleaner.mark (t, key)
|
||||
local length = #marked
|
||||
local keys = watched[t]
|
||||
if not keys then
|
||||
keys = {}
|
||||
watched[t] = keys
|
||||
elseif keys[key] then
|
||||
return
|
||||
end
|
||||
keys[key] = true
|
||||
local i = length + 1
|
||||
marked[i] = t
|
||||
marked[i + 1] = key
|
||||
end
|
||||
|
||||
function Cleaner.clean ()
|
||||
for i = #marked - 1, 1, -2 do
|
||||
local t = marked[i]
|
||||
local key = marked[i + 1]
|
||||
t[key] = nil
|
||||
marked[i] = nil
|
||||
marked[i + 1] = nil
|
||||
watched[t][key] = nil
|
||||
end
|
||||
end
|
||||
|
||||
return Cleaner
|
||||
Reference in New Issue
Block a user