about summary refs log tree commit diff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2018-05-22T11·02+0200
committerEelco Dolstra <edolstra@gmail.com>2018-05-22T11·02+0200
commit9fd7cf98dbec047343baefa65cd26ce4493bee53 (patch)
treeb9a1e8e121bdd3ee75579c6b4d4bd6cf143722e4 /src/libexpr/eval.cc
parent9064dd2f4daab34718c0143be235e8eb95c671bd (diff)
Memoise checkSourcePath()
This prevents hydra-eval-jobs from statting the same files over and
over again.
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 353097f89713..b2df14968713 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -352,6 +352,10 @@ Path EvalState::checkSourcePath(const Path & path_)
 {
     if (!allowedPaths) return path_;
 
+    auto i = resolvedPaths.find(path_);
+    if (i != resolvedPaths.end())
+        return i->second;
+
     bool found = false;
 
     for (auto & i : *allowedPaths) {
@@ -369,8 +373,10 @@ Path EvalState::checkSourcePath(const Path & path_)
     Path path = canonPath(path_, true);
 
     for (auto & i : *allowedPaths) {
-        if (isDirOrInDir(path, i))
+        if (isDirOrInDir(path, i)) {
+            resolvedPaths[path_] = path;
             return path;
+        }
     }
 
     throw RestrictedPathError("access to path '%1%' is forbidden in restricted mode", path);