diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-21 15:31:56 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-21 15:31:56 +0800 |
commit | b96ced1cc366097052097e59468a925edfdfc57e (patch) | |
tree | 5124681e5c4c2bb6390e59ccad0c34597fe7ba97 /server | |
parent | 481e8619b8da70296b02af714e0bf76b561b68a6 (diff) | |
download | lua-language-server-b96ced1cc366097052097e59468a925edfdfc57e.zip |
直接完全覆盖就行了,没必要深拷贝
Diffstat (limited to 'server')
-rw-r--r-- | server/src/matcher/vm.lua | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua index adc9df1d..a47e0109 100644 --- a/server/src/matcher/vm.lua +++ b/server/src/matcher/vm.lua @@ -189,6 +189,18 @@ function mt:buildTable(source) return tbl end +function mt:coverValue(a, b) + if a == b then + return + end + for k in pairs(a) do + a[k] = nil + end + for k, v in pairs(b) do + a[k] = v + end +end + function mt:mergeValue(a, b, mark) if a == b then return @@ -1249,9 +1261,9 @@ function mt:mergeRequire(value, strValue, destVM) uri = destVM.uri, }) else - mainValue = deepCopy(main.returns[1]) + mainValue = main.returns[1] end - self:mergeValue(value, mainValue) + self:coverValue(value, mainValue) -- 支持 require 'xxx' 的转到定义 local strSource = strValue.source @@ -1263,8 +1275,8 @@ function mt:mergeLoadFile(value, strValue, destVM) -- 取出对方的主函数 local main = destVM.results.main -- loadfile 的返回值就是对方的主函数 - local mainValue = deepCopy(main) - self:mergeValue(value, mainValue) + local mainValue = main + self:coverValue(value, mainValue) -- 支持 loadfile 'xxx.lua' 的转到定义 local strSource = strValue.source |