diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-19 15:21:23 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-19 15:21:23 +0800 |
commit | 9044f63d2e244cf01301aa6af2e62faea0e91e59 (patch) | |
tree | 2e709acfd34c56989120912fc001c9e6d28f913b /server/src/vm/value.lua | |
parent | 4087a9774bbfbad2652725684b812ed1eca43bde (diff) | |
download | lua-language-server-9044f63d2e244cf01301aa6af2e62faea0e91e59.zip |
优化
Diffstat (limited to 'server/src/vm/value.lua')
-rw-r--r-- | server/src/vm/value.lua | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua index 7ac70181..c9d8cb4b 100644 --- a/server/src/vm/value.lua +++ b/server/src/vm/value.lua @@ -40,6 +40,10 @@ local function create (tp, source, literal) end local function isDeadChild(value, index) + -- 非全局值不会出现dead child + if not value._global then + return false + end for srcId, info in pairs(value._info) do local src = sourceMgr.list[srcId] if src @@ -310,15 +314,19 @@ function mt:addInfo(tp, source, ...) self._info[id] = info self._infoCount = self._infoCount + 1 - if self._infoCount > self._infoLimit then + -- 只有全局值需要压缩info + if self._global and self._infoCount > self._infoLimit then + local count = 0 for srcId in pairs(self._info) do local src = sourceMgr.list[srcId] - if not src then + if src then + count = count + 1 + else self._info[srcId] = nil - self._infoCount = self._infoCount - 1 end end - self._infoLimit = self._infoCount * 2 + self._infoCount = count + self._infoLimit = count * 2 if self._infoLimit < 10 then self._infoLimit = 10 end |