Skip to content

Commit 54e6260

Browse files
committed
improve performance
1 parent 251f743 commit 54e6260

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

script/parser/guide.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,8 +966,6 @@ function m.getKeyName(obj)
966966
return obj[1]
967967
elseif tp == 'doc.type.field' then
968968
return obj.name[1]
969-
elseif tp == 'dummy' then
970-
return obj[1]
971969
end
972970
return m.getKeyNameOfLiteral(obj)
973971
end

script/vm/compiler.lua

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,18 @@ function vm.getClassFields(suri, node, key, pushResult)
246246

247247
local function searchGlobal(class)
248248
if class.cate == 'type' and class.name == '_G' then
249-
local sets = globalMgr.getGlobalSets(suri, 'variable')
250-
for _, set in ipairs(sets) do
251-
pushResult(set)
249+
if key == nil then
250+
local sets = globalMgr.getGlobalSets(suri, 'variable')
251+
for _, set in ipairs(sets) do
252+
pushResult(set)
253+
end
254+
else
255+
local global = globalMgr.getGlobal('variable', key)
256+
if global then
257+
for _, set in ipairs(global:getSets(suri)) do
258+
pushResult(set)
259+
end
260+
end
252261
end
253262
end
254263
end
@@ -1599,7 +1608,15 @@ local function compileByGlobal(source)
15991608
end
16001609
globalNode = vm.createNode(global)
16011610
vm.setNode(root._globalBase[name], globalNode, true)
1602-
vm.setNode(source, globalNode, true)
1611+
1612+
local sets = global.links[uri].sets or {}
1613+
local gets = global.links[uri].gets or {}
1614+
for _, set in ipairs(sets) do
1615+
vm.setNode(set, globalNode, true)
1616+
end
1617+
for _, get in ipairs(gets) do
1618+
vm.setNode(get, globalNode, true)
1619+
end
16031620

16041621
if global.cate == 'variable' then
16051622
local hasMarkDoc

0 commit comments

Comments
 (0)