summaryrefslogtreecommitdiff
path: root/script-beta/parser
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-08-16 00:52:35 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-08-16 00:52:35 +0800
commit57e5906d4050f19246bfa16365c4fb24230713d0 (patch)
tree2dbf509645d611afd6d810229de5363e023fac2f /script-beta/parser
parent68ccbc65b09026c1e8246efe46690b3b6091e09c (diff)
downloadlua-language-server-57e5906d4050f19246bfa16365c4fb24230713d0.zip
优化性能
Diffstat (limited to 'script-beta/parser')
-rw-r--r--script-beta/parser/guide.lua45
1 files changed, 25 insertions, 20 deletions
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua
index 9f479f17..650b6e51 100644
--- a/script-beta/parser/guide.lua
+++ b/script-beta/parser/guide.lua
@@ -1254,26 +1254,29 @@ function m.checkSameSimpleInCall(status, ref, start, queue, mode)
if not func then
return
end
+ if m.checkCallMark(status, func.parent, true) then
+ return
+ end
local objs = m.checkSameSimpleInCallInSameFile(status, func, args, index)
if status.interface.call then
local cobjs = status.interface.call(func, args, index)
if cobjs then
for _, obj in ipairs(cobjs) do
- objs[#objs+1] = obj
+ if not m.checkReturnMark(status, obj) then
+ objs[#objs+1] = obj
+ end
end
end
end
local newStatus = m.status(status)
for _, obj in ipairs(objs) do
- if not m.checkCallMark(status, obj) then
- m.searchRefs(newStatus, obj, mode)
- queue[#queue+1] = {
- obj = obj,
- start = start,
- force = true,
- call = true,
- }
- end
+ m.searchRefs(newStatus, obj, mode)
+ queue[#queue+1] = {
+ obj = obj,
+ start = start,
+ force = true,
+ call = true,
+ }
end
for _, obj in ipairs(newStatus.results) do
queue[#queue+1] = {
@@ -1324,25 +1327,25 @@ function m.checkValueMark(status, a, b)
return false
end
-function m.checkCallMark(status, a)
+function m.checkCallMark(status, a, mark)
if not status.cache.callMark then
status.cache.callMark = {}
end
if status.cache.callMark[a] then
return true
end
- status.cache.callMark[a] = true
+ status.cache.callMark[a] = mark
return false
end
-function m.checkReturnMark(status, a)
+function m.checkReturnMark(status, a, mark)
if not status.cache.returnMark then
status.cache.returnMark = {}
end
if status.cache.returnMark[a] then
return true
end
- status.cache.returnMark[a] = true
+ status.cache.returnMark[a] = mark
return false
end
@@ -1396,11 +1399,13 @@ function m.checkSameSimpleAsReturn(status, ref, start, queue)
local newStatus = m.status(status)
m.searchRefsAsFunctionReturn(newStatus, ref, 'ref')
for _, res in ipairs(newStatus.results) do
- queue[#queue+1] = {
- obj = res,
- start = start,
- force = true,
- }
+ if not m.checkCallMark(status, res) then
+ queue[#queue+1] = {
+ obj = res,
+ start = start,
+ force = true,
+ }
+ end
end
end
@@ -1650,7 +1655,7 @@ function m.searchRefsAsFunctionReturn(status, obj, mode)
if mode == 'def' then
return
end
- if m.checkReturnMark(status, obj) then
+ if m.checkReturnMark(status, obj, true) then
return
end
status.results[#status.results+1] = obj