diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-03-03 17:41:52 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-03-03 17:41:52 +0800 |
commit | fb63bf2123b3838690b40c2d46279ac96c78dbbd (patch) | |
tree | 7f4b09381c17d5669a7c145f8f2505aefd56bf35 /script | |
parent | 0eefe4e446efc39ed2256917079c68e66de2ad20 (diff) | |
download | lua-language-server-fb63bf2123b3838690b40c2d46279ac96c78dbbd.zip |
improve performance
Diffstat (limited to 'script')
-rw-r--r-- | script/parser/guide.lua | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/script/parser/guide.lua b/script/parser/guide.lua index 32bc4fef..f5ca1158 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -2183,17 +2183,33 @@ local function checkSameSimpleAndMergeDocTypeFunctionReturns(status, results, so end function m.checkSameSimpleInCallInSameFile(status, func, args, index) - local results = {} + if not status.share.callResultsCache then + status.share.callResultsCache = {} + end + local cache = status.share.callResultsCache[func] + if not cache then + cache = {} + status.share.callResultsCache[func] = cache + end + local results = cache[index] + if results then + return results + end + results = {} if func.special then --return results end local newStatus = m.status(status) m.searchRefs(newStatus, func, 'def') + local hasDocReturn for _, def in ipairs(newStatus.results) do - local hasDocReturn = checkSameSimpleAndMergeDocTypeFunctionReturns(status, results, def, index) - or checkSameSimpleAndMergeFunctionReturnsByDoc(status, results, def, index, args) - or checkSameSimpleAndMergeDocFunctionReturn(status, results, def, index, args) - if not hasDocReturn then + hasDocReturn = checkSameSimpleAndMergeDocTypeFunctionReturns(status, results, def, index) + or checkSameSimpleAndMergeFunctionReturnsByDoc(status, results, def, index, args) + or checkSameSimpleAndMergeDocFunctionReturn(status, results, def, index, args) + or hasDocReturn + end + if not hasDocReturn then + for _, def in ipairs(newStatus.results) do local value = m.getObjectValue(def) or def if value.type == 'function' then local returns = value.returns @@ -2207,6 +2223,8 @@ function m.checkSameSimpleInCallInSameFile(status, func, args, index) end end end + -- generic cannot cache + cache[index] = results end return results end |