summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeOzay <colpaert.benoit@gmail.com>2024-07-28 18:30:02 +0200
committerNeOzay <colpaert.benoit@gmail.com>2024-07-28 18:30:02 +0200
commitdf9db56b148f8ab242d35f7d4e2b91cd2ba02668 (patch)
treecb624ab7bb295cec047e2742350c05783074e3fd
parent9035afd4b4fb548c2d88c0a4e3ec566cb0c2cc11 (diff)
downloadlua-language-server-df9db56b148f8ab242d35f7d4e2b91cd2ba02668.zip
compute table keys once
-rw-r--r--script/core/diagnostics/missing-fields.lua17
1 files changed, 10 insertions, 7 deletions
diff --git a/script/core/diagnostics/missing-fields.lua b/script/core/diagnostics/missing-fields.lua
index d332b091..5ce650ec 100644
--- a/script/core/diagnostics/missing-fields.lua
+++ b/script/core/diagnostics/missing-fields.lua
@@ -35,7 +35,8 @@ return function (uri, callback)
return
end
end
-
+
+ local myKeys
local warnings = {}
for className, samedefs in pairs(sortedDefs) do
local missedKeys = {}
@@ -43,12 +44,14 @@ return function (uri, callback)
if not def.fields or #def.fields == 0 then
goto continue
end
-
- local myKeys = {}
- for _, field in ipairs(src) do
- local key = vm.getKeyName(field) or field.tindex
- if key then
- myKeys[key] = true
+
+ if not myKeys then
+ myKeys = {}
+ for _, field in ipairs(src) do
+ local key = vm.getKeyName(field) or field.tindex
+ if key then
+ myKeys[key] = true
+ end
end
end