Skip to content

perf: searchSameFields: return early when obj was already locked #564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions script/core/guide.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down