From ba6cecf5d9f233dbdcfe5b721e9794658f74e056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 7 Jun 2022 17:06:45 +0800 Subject: #1192 improve local id In most cases, we only need to get `sets`. In general, there are few `sets` and many `gets`. Therefore, separating these two cases can significantly improve performance. --- script/vm/ref.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'script/vm/ref.lua') diff --git a/script/vm/ref.lua b/script/vm/ref.lua index fbb9d015..031a2e69 100644 --- a/script/vm/ref.lua +++ b/script/vm/ref.lua @@ -240,12 +240,17 @@ end ---@param source parser.object ---@param pushResult fun(src: parser.object) local function searchByLocalID(source, pushResult) - local idSources = vm.getLocalSources(source) - if not idSources then - return + local sourceSets = vm.getLocalSourcesSets(source) + if sourceSets then + for _, src in ipairs(sourceSets) do + pushResult(src) + end end - for _, src in ipairs(idSources) do - pushResult(src) + local sourceGets = vm.getLocalSourcesGets(source) + if sourceGets then + for _, src in ipairs(sourceGets) do + pushResult(src) + end end end -- cgit v1.2.3