summaryrefslogtreecommitdiff
path: root/script/vm/node.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-15 19:24:46 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-15 19:24:46 +0800
commit491876016134b50680667053177faeae411aa9a2 (patch)
treeb38c5ba204cb1d9d4fc25eeb30a2f97c0815c076 /script/vm/node.lua
parentb4524f05ee0a21176cb9a0e22941b04a3eca3773 (diff)
downloadlua-language-server-491876016134b50680667053177faeae411aa9a2.zip
improve performance
Diffstat (limited to 'script/vm/node.lua')
-rw-r--r--script/vm/node.lua19
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