diff options
author | sumneko <sumneko@hotmail.com> | 2019-04-12 13:44:44 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-04-12 13:44:44 +0800 |
commit | 90fede5418b7c612ca18821e4616664acf11783e (patch) | |
tree | cf8da57e61feeed67300566dbffe4669986b3ab7 /server/src/vm | |
parent | f9dde0cfbfc3a76f5fb751e01f7c372d13a302b2 (diff) | |
download | lua-language-server-90fede5418b7c612ca18821e4616664acf11783e.zip |
全局变量清理info使用标记,加快大量全局变量的操作速度
Diffstat (limited to 'server/src/vm')
-rw-r--r-- | server/src/vm/value.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua index 162a5619..9ffd55bc 100644 --- a/server/src/vm/value.lua +++ b/server/src/vm/value.lua @@ -225,6 +225,7 @@ function mt:flushChild() end infos._count = count infos._limit = count + 10 + infos._version = listMgr.getVersion() for index in pairs(self._child) do if not alived[index] then self._child[index] = nil @@ -390,8 +391,9 @@ function mt:addInfo(tp, source, ...) } infos[id] = info infos._count = (infos._count or 0) + 1 + local version = listMgr.getVersion() -- 只有全局值需要压缩info - if self._global and infos._count > (infos._limit or 10) then + if self._global and infos._count > (infos._limit or 10) and infos._version ~= version then local count = 0 for srcId in pairs(infos) do local src = listMgr.get(srcId) @@ -403,6 +405,7 @@ function mt:addInfo(tp, source, ...) end infos._count = count infos._limit = count + 10 + infos._version = version end end @@ -419,6 +422,7 @@ function mt:eachInfo(callback) end infos._count = #list infos._limit = infos._count + 10 + infos._version = listMgr.getVersion() table.sort(list, function (a, b) return a._sort < b._sort end) |