From 521feda953a686ad876186366391340f945ca65b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 4 Nov 2019 18:22:51 +0800 Subject: =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=AF=8A=E6=96=AD=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-beta/src/parser/guide.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'server-beta/src/parser') 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 -- cgit v1.2.3