diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-11-20 21:55:41 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-11-20 21:55:41 +0800 |
commit | c63b2e404d8d2bb984afe3678a5ba2b2836380cc (patch) | |
tree | a70661effacc7a29caa8d49583673ac4be2faaf5 /script/vm/chain.lua | |
parent | 85c5a4210e4447422cd5677369ae740ed65725a0 (diff) | |
download | lua-language-server-c63b2e404d8d2bb984afe3678a5ba2b2836380cc.zip |
remove the old version
Diffstat (limited to 'script/vm/chain.lua')
-rw-r--r-- | script/vm/chain.lua | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/script/vm/chain.lua b/script/vm/chain.lua deleted file mode 100644 index 6e7c6ac7..00000000 --- a/script/vm/chain.lua +++ /dev/null @@ -1,65 +0,0 @@ -local valueMgr = require 'vm.value' -local sourceMgr = require 'vm.source' - -local mt = {} -mt.__index = mt -mt.type = 'chain' - -mt.min = 100 -mt.max = 100 -mt.count = 0 - -function mt:clearCache() - if self.count <= self.max then - return - end - local clock = os.clock() - local n = 0 - for uri, value in pairs(self.cache) do - local ok = value:eachInfo(function () - return true - end) - if ok then - n = n + 1 - else - value:getSource():kill() - self.cache[uri] = nil - end - end - self.count = n - self.max = self.count * 1.1 + 10 - if self.max < self.min then - self.max = self.min - end - local passed = os.clock() - clock - if passed > 0.1 then - log.warn(('chain:clearCache takes: [%.3f]sec, self.count: %d'):format(passed, self.count)) - end -end - -function mt:get(uri) - if not self.cache[uri] then - self.count = self.count + 1 - self:clearCache() - self.cache[uri] = valueMgr.create('any', sourceMgr.dummy()) - self.cache[uri]:markGlobal() - self.cache[uri].uri = uri - end - return self.cache[uri] -end - -function mt:remove() - if self.removed then - return - end - self.removed = true - for _, value in pairs(self.cache) do - value:getSource():kill() - end -end - -return function () - return setmetatable({ - cache = {}, - }, mt) -end |