summaryrefslogtreecommitdiff
path: root/script/vm/infer.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-01-16 17:39:08 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-01-16 17:39:08 +0800
commit861327485e9c9795cd00635feb41a74d396448db (patch)
treecc9705075a9d37091f09f6736069a6eda2bbbcde /script/vm/infer.lua
parent15fa11654114e7451d64a726f6ad9d6abbd92b35 (diff)
downloadlua-language-server-861327485e9c9795cd00635feb41a74d396448db.zip
improve performance for large alias struct
fix #1811
Diffstat (limited to 'script/vm/infer.lua')
-rw-r--r--script/vm/infer.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/script/vm/infer.lua b/script/vm/infer.lua
index e78be910..0b5a6dcb 100644
--- a/script/vm/infer.lua
+++ b/script/vm/infer.lua
@@ -8,6 +8,9 @@ local vm = require 'vm.vm'
---@field node vm.node
---@field views table<string, boolean>
---@field _drop table
+---@field _lastView? string
+---@field _lastViewUri? uri
+---@field _lastViewDefault? any
local mt = {}
mt.__index = mt
mt._hasTable = false
@@ -390,9 +393,18 @@ end
---@param default? string
---@return string
function mt:view(uri, default)
+ if self._lastView
+ and self._lastViewUri == uri
+ and self._lastViewDefault == default then
+ return self._lastView
+ end
+ self._lastViewUri = uri
+ self._lastViewDefault = default
+
self:_computeViews(uri)
if self.views['any'] then
+ self._lastView = 'any'
return 'any'
end
@@ -445,6 +457,11 @@ function mt:view(uri, default)
end
end
+ if #view > 200 then
+ view = view:sub(1, 180) .. '...(too long)...' .. view:sub(-10)
+ end
+
+ self._lastView = view
return view
end