From e4e341832d609f13857795a62cec861850d80b7a Mon Sep 17 00:00:00 2001 From: kikito Date: Mon, 29 Oct 2012 20:32:23 +0100 Subject: [PATCH] made scopecache weak. Fixes #7 --- cron.lua | 4 ++-- spec/cron_spec.lua | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/cron.lua b/cron.lua index de0a823..0dc2fa9 100644 --- a/cron.lua +++ b/cron.lua @@ -109,7 +109,7 @@ local function storeScopeInCache(scope) local node = scopeCacheRoot for i=1, scope.len do 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] end node.scope = scope @@ -165,7 +165,7 @@ end function cron.reset() entries = {} taggedEntries = setmetatable({}, {__mode='k'}) - scopeCacheRoot = { children = {}} + scopeCacheRoot = { children = setmetatable({}, {__mode='k'}) } end -- tagged functions diff --git a/spec/cron_spec.lua b/spec/cron_spec.lua index 98eeb49..9b7287e 100644 --- a/spec/cron_spec.lua +++ b/spec/cron_spec.lua @@ -159,8 +159,5 @@ describe( 'cron', function() assert_equal(counter, 4) end) - it('caches scopes', function() - assert_equal(cron.tagged('hello', 'world'), cron.tagged('hello', 'world')) - end) end) end)