summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorFolke Lemaitre <folke.lemaitre@gmail.com>2021-06-17 10:40:03 +0200
committerFolke Lemaitre <folke.lemaitre@gmail.com>2021-06-17 10:40:03 +0200
commit4bb80e039198ceb2e45bb51d46d7013eacc8f452 (patch)
treee57223ce67b2fac1cad2068e964930a490d086d1 /script
parent24b3c06cd70050fc98e3946cfd343395d4f11ddf (diff)
downloadlua-language-server-4bb80e039198ceb2e45bb51d46d7013eacc8f452.zip
perf: searchSameFields: return early when obj was already locked
Diffstat (limited to 'script')
-rw-r--r--script/core/guide.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/script/core/guide.lua b/script/core/guide.lua
index e4871060..c7a784b7 100644
--- a/script/core/guide.lua
+++ b/script/core/guide.lua
@@ -3016,7 +3016,7 @@ function m.searchSameFields(status, simple, mode)
locks[start] = lock
end
if lock[obj] then
- return
+ return false
end
lock[obj] = true
queueLen = queueLen + 1
@@ -3032,13 +3032,17 @@ function m.searchSameFields(status, simple, mode)
forces[queueLen] = force
end
end
+ return true
end
local function pushQueue(obj, start, force)
if obj.type == 'getlocal'
or obj.type == 'setlocal' then
obj = obj.node
end
- appendQueue(obj, start, force)
+ if appendQueue(obj, start, force) == false then
+ -- no need to process the rest if obj is already locked
+ return
+ end
if obj.type == 'local' and obj.ref then
for _, ref in ipairs(obj.ref) do
appendQueue(ref, start, force)