summaryrefslogtreecommitdiff
path: root/tex/context/base/data-exp.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2011-06-23 19:25:00 +0200
committerHans Hagen <pragma@wxs.nl>2011-06-23 19:25:00 +0200
commitbddac3f564687065474739c7face6fcd93ceea69 (patch)
tree26cb1a2ca4bf35c232da5b74347cb6aa5040a4da /tex/context/base/data-exp.lua
parent4001733dc25cb6743004db0e9319708481d91135 (diff)
downloadcontext-bddac3f564687065474739c7face6fcd93ceea69.tar.gz
beta 2011.06.23 19:25
Diffstat (limited to 'tex/context/base/data-exp.lua')
-rw-r--r--tex/context/base/data-exp.lua51
1 files changed, 36 insertions, 15 deletions
diff --git a/tex/context/base/data-exp.lua b/tex/context/base/data-exp.lua
index 86a287dd4..6083ffc2d 100644
--- a/tex/context/base/data-exp.lua
+++ b/tex/context/base/data-exp.lua
@@ -26,19 +26,6 @@ local resolvers = resolvers
-- all, when working on the main resolver code, I don't want to scroll
-- past this every time. See data-obs.lua for the gsub variant.
--- {a,b,c,d}
--- a,b,c/{p,q,r},d
--- a,b,c/{p,q,r}/d/{x,y,z}//
--- a,b,c/{p,q/{x,y,z},r},d/{p,q,r}
--- a,b,c/{p,q/{x,y,z},r},d/{p,q,r}
--- a{b,c}{d,e}f
--- {a,b,c,d}
--- {a,b,c/{p,q,r},d}
--- {a,b,c/{p,q,r}/d/{x,y,z}//}
--- {a,b,c/{p,q/{x,y,z}},d/{p,q,r}}
--- {a,b,c/{p,q/{x,y,z},w}v,d/{p,q,r}}
--- {$SELFAUTODIR,$SELFAUTOPARENT}{,{/share,}/texmf{-local,.local,}/web2c}
-
local function f_first(a,b)
local t, n = { }, 0
for s in gmatch(b,"[^,]+") do
@@ -130,6 +117,19 @@ function resolvers.expandedpathfromlist(pathlist)
return newlist
end
+-- {a,b,c,d}
+-- a,b,c/{p,q,r},d
+-- a,b,c/{p,q,r}/d/{x,y,z}//
+-- a,b,c/{p,q/{x,y,z},r},d/{p,q,r}
+-- a,b,c/{p,q/{x,y,z},r},d/{p,q,r}
+-- a{b,c}{d,e}f
+-- {a,b,c,d}
+-- {a,b,c/{p,q,r},d}
+-- {a,b,c/{p,q,r}/d/{x,y,z}//}
+-- {a,b,c/{p,q/{x,y,z}},d/{p,q,r}}
+-- {a,b,c/{p,q/{x,y,z},w}v,d/{p,q,r}}
+-- {$SELFAUTODIR,$SELFAUTOPARENT}{,{/share,}/texmf{-local,.local,}/web2c}
+
local cleanup = lpeg.replacer {
{ "!" , "" },
{ "\\" , "/" },
@@ -311,9 +311,21 @@ local function scan(files,spec,path,n,m,r)
return files, n, m, r
end
-function resolvers.scanfiles(path,branch)
+local cache = { }
+
+function resolvers.scanfiles(path,branch,usecache)
+ statistics.starttiming(cache)
+ if usecache then
+ local files = cache[path]
+ if files then
+ if trace_locating then
+ report_expansions("using caches scan of path '%s', branch '%s'",path,branch or path)
+ end
+ return files
+ end
+ end
if trace_locating then
- report_expansions("scanning path '%s', branch '%s'",path, branch or path)
+ report_expansions("scanning path '%s', branch '%s'",path,branch or path)
end
local realpath = resolvers.resolve(path) -- no shortcut
local files, n, m, r = scan({ },realpath .. '/',"",0,0,0)
@@ -324,7 +336,16 @@ function resolvers.scanfiles(path,branch)
if trace_locating then
report_expansions("%s files found on %s directories with %s uppercase remappings",n,m,r)
end
+ if usecache then
+ cache[path] = files
+ end
+ statistics.stoptiming(cache)
return files
end
+function resolvers.scantime()
+ return statistics.elapsedtime(cache)
+end
+
+
--~ print(table.serialize(resolvers.scanfiles("t:/sources")))