summaryrefslogtreecommitdiff
path: root/server-beta/src/parser
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta/src/parser')
-rw-r--r--server-beta/src/parser/guide.lua17
1 files changed, 10 insertions, 7 deletions
diff --git a/server-beta/src/parser/guide.lua b/server-beta/src/parser/guide.lua
index 773fb6d5..d8dd873e 100644
--- a/server-beta/src/parser/guide.lua
+++ b/server-beta/src/parser/guide.lua
@@ -309,16 +309,19 @@ end
--- 遍历所有指定类型的source
function m.eachSourceType(ast, type, callback)
- local cache = ast.typeCache
+ if not ast.typeCache then
+ ast.typeCache = {}
+ end
+ local cache = ast.typeCache[type]
if not cache then
cache = {}
- ast.typeCache = cache
- m.eachSource(ast, function (source)
- if source.type == type then
- cache[#cache+1] = source
- end
- end)
+ ast.typeCache[type] = cache
end
+ m.eachSource(ast, function (source)
+ if source.type == type then
+ cache[#cache+1] = source
+ end
+ end)
for i = 1, #cache do
callback(cache[i])
end