summaryrefslogtreecommitdiff
path: root/lib/gitano/util.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitano/util.lua')
-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