summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-03-25 10:21:54 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-03-25 10:21:54 +0800
commit0ac45b3968f49f12f5886d301d992c3dffe02ca1 (patch)
tree88cfc6f78743618cd11914537474e90382d69c60
parent79d2d47cd1d80bc60b1a68ea9b552fdb463fff8e (diff)
downloadlua-language-server-0ac45b3968f49f12f5886d301d992c3dffe02ca1.zip
优化性能
-rw-r--r--server/src/vm/value.lua15
1 files changed, 14 insertions, 1 deletions
diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua
index 9fd1fdf1..4cbc47f9 100644
--- a/server/src/vm/value.lua
+++ b/server/src/vm/value.lua
@@ -204,6 +204,19 @@ function mt:rawEach(callback, foundIndex)
if not self._child then
return nil
end
+ local alived
+ -- 非全局值不会出现dead child
+ if self._global then
+ alived = {}
+ for srcId, info in pairs(self._info) do
+ local src = sourceMgr.list[srcId]
+ if src
+ and (info.type == 'set child' or info.type == 'get child')
+ then
+ alived[info[1]] = true
+ end
+ end
+ end
for index, value in pairs(self._child) do
if foundIndex then
if foundIndex[index] then
@@ -211,7 +224,7 @@ function mt:rawEach(callback, foundIndex)
end
foundIndex[index] = true
end
- if isDeadChild(self, index) then
+ if alived and not alived[index] then
self._child[index] = nil
goto CONTINUE
end