Skip to content

Commit 8613274

Browse files
committed
improve performance for large alias struct
fix #1811
1 parent 15fa116 commit 8613274

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
* `FIX` [#1751]
1515
* `FIX` [#1767]
1616
* `FIX` [#1808]
17+
* `FIX` [#1811]
1718

1819
[#831]: https://github.com/sumneko/lua-language-server/issues/831
1920
[#1729]: https://github.com/sumneko/lua-language-server/issues/1729
2021
[#1737]: https://github.com/sumneko/lua-language-server/issues/1737
2122
[#1751]: https://github.com/sumneko/lua-language-server/issues/1751
2223
[#1767]: https://github.com/sumneko/lua-language-server/issues/1767
2324
[#1808]: https://github.com/sumneko/lua-language-server/issues/1808
25+
[#1811]: https://github.com/sumneko/lua-language-server/issues/1811
2426

2527
`2022-11-29`
2628
## 3.6.4

script/vm/infer.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ local vm = require 'vm.vm'
88
---@field node vm.node
99
---@field views table<string, boolean>
1010
---@field _drop table
11+
---@field _lastView? string
12+
---@field _lastViewUri? uri
13+
---@field _lastViewDefault? any
1114
local mt = {}
1215
mt.__index = mt
1316
mt._hasTable = false
@@ -390,9 +393,18 @@ end
390393
---@param default? string
391394
---@return string
392395
function mt:view(uri, default)
396+
if self._lastView
397+
and self._lastViewUri == uri
398+
and self._lastViewDefault == default then
399+
return self._lastView
400+
end
401+
self._lastViewUri = uri
402+
self._lastViewDefault = default
403+
393404
self:_computeViews(uri)
394405

395406
if self.views['any'] then
407+
self._lastView = 'any'
396408
return 'any'
397409
end
398410

@@ -445,6 +457,11 @@ function mt:view(uri, default)
445457
end
446458
end
447459

460+
if #view > 200 then
461+
view = view:sub(1, 180) .. '...(too long)...' .. view:sub(-10)
462+
end
463+
464+
self._lastView = view
448465
return view
449466
end
450467

script/vm/type.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ local function checkValue(parent, child, mark, errs)
221221

222222
if parent.type == 'doc.type.table' then
223223
if child.type == 'doc.type.table' then
224+
if child == parent then
225+
return true
226+
end
224227
---@cast parent parser.object
225228
---@cast child parser.object
226229
local uri = guide.getUri(parent)

0 commit comments

Comments
 (0)