summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2014-03-22 18:33:33 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2014-03-22 18:33:33 +0000
commit69085b691188bdb6d1345eeaeb94f0f3f1506f70 (patch)
tree4c9e615f4a2c100bec5303e805a9d17e80667467
parentb5503750fcf752ba612d388e6cf3c39d86e38c73 (diff)
downloadgitano-69085b691188bdb6d1345eeaeb94f0f3f1506f70.tar.bz2
Cache expansions
-rw-r--r--lib/gitano/util.lua8
1 files changed, 8 insertions, 0 deletions
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