diff options
Diffstat (limited to 'server-beta/src/searcher/isGlobal.lua')
-rw-r--r-- | server-beta/src/searcher/isGlobal.lua | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/server-beta/src/searcher/isGlobal.lua b/server-beta/src/searcher/isGlobal.lua index 549220a9..d59a6876 100644 --- a/server-beta/src/searcher/isGlobal.lua +++ b/server-beta/src/searcher/isGlobal.lua @@ -1,15 +1,29 @@ local searcher = require 'searcher.searcher' -function searcher.isGlobal(source) +local function isGlobal(source) local node = source.node if not node then return false end - local isGlobal + local global searcher.eachRef(node, function (info) if info.source.tag == '_ENV' then - isGlobal = true + global = true end end) - return isGlobal + return global +end + +function searcher.isGlobal(source) + local cache = searcher.cache.isGlobal[source] + if cache ~= nil then + return cache + end + cache = isGlobal(source) + searcher.cache.isGlobal[source] = cache + searcher.eachRef(source, function (info) + local src = info.source + searcher.cache.isGlobal[src] = cache + end) + return cache end |