From 69085b691188bdb6d1345eeaeb94f0f3f1506f70 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 22 Mar 2014 18:33:33 +0000 Subject: Cache expansions --- lib/gitano/util.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/gitano/util.lua b/lib/gitano/util.lua index c2a53a7..291c68d 100644 --- a/lib/gitano/util.lua +++ b/lib/gitano/util.lua @@ -337,12 +337,18 @@ end local tagname_pattern = "^[a-z0-9_%-/]*[a-z0-9_%-]*$" +local cached_expansions = {} + local function prep_expansion(str) -- Parse 'str' and return a table representing a sequence of -- operations required to evaluate the expansion of the string. -- in the simple case, it's merely the string in a table -- if the entry in ret is a string, it's copied. If it's a table -- then that table's [1] is a string which is a tag name to expand. + if cached_expansions[str] then + return cached_expansions[str] + end + local ret = {} local acc = "" local c @@ -386,6 +392,8 @@ local function prep_expansion(str) ret[#ret+1] = acc end + cached_expansions[str] = ret + return ret end -- cgit v1.2.1