diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-15 19:24:46 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-15 19:24:46 +0800 |
commit | 491876016134b50680667053177faeae411aa9a2 (patch) | |
tree | b38c5ba204cb1d9d4fc25eeb30a2f97c0815c076 /script/vm/node.lua | |
parent | b4524f05ee0a21176cb9a0e22941b04a3eca3773 (diff) | |
download | lua-language-server-491876016134b50680667053177faeae411aa9a2.zip |
improve performance
Diffstat (limited to 'script/vm/node.lua')
-rw-r--r-- | script/vm/node.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/script/vm/node.lua b/script/vm/node.lua index ea6a5874..21f95a49 100644 --- a/script/vm/node.lua +++ b/script/vm/node.lua @@ -232,7 +232,26 @@ function vm.removeNode(source) vm.nodeCache[source] = nil end +local lockCount = 0 +local needClearCache = false +function vm.lockCache() + lockCount = lockCount + 1 +end + +function vm.unlockCache() + lockCount = lockCount - 1 + if needClearCache then + needClearCache = false + vm.clearNodeCache() + end +end + function vm.clearNodeCache() + if lockCount > 0 then + needClearCache = true + return + end + log.debug('clearNodeCache') vm.nodeCache = {} end |