made scopecache weak. Fixes #7

This commit is contained in:
kikito 2012-10-29 20:32:23 +01:00
parent 4ea9f257a8
commit e4e341832d
2 changed files with 2 additions and 5 deletions

View File

@ -109,7 +109,7 @@ local function storeScopeInCache(scope)
local node = scopeCacheRoot local node = scopeCacheRoot
for i=1, scope.len do for i=1, scope.len do
local tag = scope.tags[i] local tag = scope.tags[i]
node.children[tag] = node.children[tag] or { children={} } node.children[tag] = node.children[tag] or { children=setmetatable({},{__mode='k'}) }
node = node.children[tag] node = node.children[tag]
end end
node.scope = scope node.scope = scope
@ -165,7 +165,7 @@ end
function cron.reset() function cron.reset()
entries = {} entries = {}
taggedEntries = setmetatable({}, {__mode='k'}) taggedEntries = setmetatable({}, {__mode='k'})
scopeCacheRoot = { children = {}} scopeCacheRoot = { children = setmetatable({}, {__mode='k'}) }
end end
-- tagged functions -- tagged functions

View File

@ -159,8 +159,5 @@ describe( 'cron', function()
assert_equal(counter, 4) assert_equal(counter, 4)
end) end)
it('caches scopes', function()
assert_equal(cron.tagged('hello', 'world'), cron.tagged('hello', 'world'))
end)
end) end)
end) end)