summaryrefslogtreecommitdiff
path: root/script/vm/local-id.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-15 19:10:46 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-15 19:10:46 +0800
commitb4524f05ee0a21176cb9a0e22941b04a3eca3773 (patch)
treeb93dcbe480f103866a9ecbeddb614ac8590daacf /script/vm/local-id.lua
parent54e6260b2ac36c4653a30ed5ab5e17d3e7f0abd9 (diff)
downloadlua-language-server-b4524f05ee0a21176cb9a0e22941b04a3eca3773.zip
improve performance
Diffstat (limited to 'script/vm/local-id.lua')
-rw-r--r--script/vm/local-id.lua15
1 files changed, 7 insertions, 8 deletions
diff --git a/script/vm/local-id.lua b/script/vm/local-id.lua
index aa4f3118..728de301 100644
--- a/script/vm/local-id.lua
+++ b/script/vm/local-id.lua
@@ -1,5 +1,6 @@
local util = require 'utility'
local guide = require 'parser.guide'
+local vm = require 'vm.vm'
---@class parser.object
---@field _localID string
@@ -8,8 +9,6 @@ local guide = require 'parser.guide'
---@class vm.local-id
local m = {}
-m.ID_SPLITE = '\x1F'
-
local compileSwitch = util.switch()
: case 'local'
: case 'self'
@@ -38,7 +37,7 @@ local compileSwitch = util.switch()
if type(key) ~= 'string' then
return
end
- source._localID = parentID .. m.ID_SPLITE .. key
+ source._localID = parentID .. vm.ID_SPLITE .. key
source.field._localID = source._localID
if source.type == 'getfield' then
m.compileLocalID(source.next)
@@ -55,7 +54,7 @@ local compileSwitch = util.switch()
if type(key) ~= 'string' then
return
end
- source._localID = parentID .. m.ID_SPLITE .. key
+ source._localID = parentID .. vm.ID_SPLITE .. key
source.method._localID = source._localID
if source.type == 'getmethod' then
m.compileLocalID(source.next)
@@ -72,7 +71,7 @@ local compileSwitch = util.switch()
if type(key) ~= 'string' then
return
end
- source._localID = parentID .. m.ID_SPLITE .. key
+ source._localID = parentID .. vm.ID_SPLITE .. key
source.index._localID = source._localID
if source.type == 'setindex' then
m.compileLocalID(source.next)
@@ -160,7 +159,7 @@ function m.getSources(source, key)
if type(key) ~= 'string' then
return nil
end
- id = id .. m.ID_SPLITE .. key
+ id = id .. vm.ID_SPLITE .. key
end
return root._localIDs[id]
end
@@ -182,9 +181,9 @@ function m.getFields(source)
for lid, sources in pairs(root._localIDs) do
if lid ~= id
and util.stringStartWith(lid, id)
- and lid:sub(#id + 1, #id + 1) == m.ID_SPLITE
+ and lid:sub(#id + 1, #id + 1) == vm.ID_SPLITE
-- only one field
- and not lid:find(m.ID_SPLITE, #id + 2) then
+ and not lid:find(vm.ID_SPLITE, #id + 2) then
for _, src in ipairs(sources) do
fields[#fields+1] = src
end