diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-07-30 16:37:31 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-07-30 16:37:31 +0800 |
commit | d8d82910565406fe86651e498a37aa45e663976a (patch) | |
tree | 96e20e567f3ca889b0b10c41d73cf4a4aa11d054 /script/vm | |
parent | 9f701d9a8a2ad3938dd857bc21f25e65209cfe1e (diff) | |
download | lua-language-server-d8d82910565406fe86651e498a37aa45e663976a.zip |
improve memory usage
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/getDocs.lua | 4 | ||||
-rw-r--r-- | script/vm/getGlobals.lua | 17 |
2 files changed, 15 insertions, 6 deletions
diff --git a/script/vm/getDocs.lua b/script/vm/getDocs.lua index e8fefb7a..58de5680 100644 --- a/script/vm/getDocs.lua +++ b/script/vm/getDocs.lua @@ -18,8 +18,8 @@ function vm.getDocDefines(name) end local results = {} local id = 'def:dn:' .. name - for node in collector.each(id) do - for source in noder.eachSource(node) do + for noders in collector.each(id) do + for source in noder.eachSource(noders, id) do if source.type == 'doc.class.name' or source.type == 'doc.alias.name' then results[#results+1] = source diff --git a/script/vm/getGlobals.lua b/script/vm/getGlobals.lua index 696f218e..f2117d07 100644 --- a/script/vm/getGlobals.lua +++ b/script/vm/getGlobals.lua @@ -4,7 +4,12 @@ local vm = require 'vm.vm' local noder = require 'core.noder' function vm.hasGlobalSets(name) - local id = ('def:g:%q'):format(name) + local id + if type(name) == 'string' then + id = ('def:g:%s%s'):format(noder.STRING_CHAR, name) + else + id = ('def:g:%s'):format(noder.STRING_CHAR, name) + end return collector.has(id) end @@ -19,10 +24,14 @@ function vm.getGlobalSets(name) if name == '*' then id = 'def:g:' else - id = ('def:g:%q'):format(name) + if type(name) == 'string' then + id = ('def:g:%s%s'):format(noder.STRING_CHAR, name) + else + id = ('def:g:%s'):format(noder.STRING_CHAR, name) + end end - for node in collector.each(id) do - for source in noder.eachSource(node) do + for noders in collector.each(id) do + for source in noder.eachSource(noders, id) do results[#results+1] = source end end |