diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-01-16 17:39:08 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-01-16 17:39:08 +0800 |
commit | 861327485e9c9795cd00635feb41a74d396448db (patch) | |
tree | cc9705075a9d37091f09f6736069a6eda2bbbcde /script/vm/infer.lua | |
parent | 15fa11654114e7451d64a726f6ad9d6abbd92b35 (diff) | |
download | lua-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.lua | 17 |
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 |