diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-10-23 11:16:46 +0000 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-10-23 11:19:01 +0000 |
commit | fe95650487d189bae2be198fe2cbbb0cb6c3788f (patch) | |
tree | 04108733590ba30df2647886cb36778e44594733 /src/libexpr | |
parent | 3139481822b770a5ad1f81f447ef31ed5446bc72 (diff) | |
download | guix-fe95650487d189bae2be198fe2cbbb0cb6c3788f.tar.gz |
Memoize evalFile() lookups under both the original and resolved name
Previously we only used the resolved name, causing repeated resolution (e.g. /dir to /dir/default.nix).
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/eval.cc | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 59c42d0b0d..300e184328 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -436,10 +436,14 @@ Value * ExprPath::maybeThunk(EvalState & state, Env & env) void EvalState::evalFile(const Path & path, Value & v) { - Path path2 = resolveExprPath(path); + FileEvalCache::iterator i; + if ((i = fileEvalCache.find(path)) != fileEvalCache.end()) { + v = i->second; + return; + } - FileEvalCache::iterator i = fileEvalCache.find(path2); - if (i != fileEvalCache.end()) { + Path path2 = resolveExprPath(path); + if ((i = fileEvalCache.find(path2)) != fileEvalCache.end()) { v = i->second; return; } @@ -452,8 +456,9 @@ void EvalState::evalFile(const Path & path, Value & v) addErrorPrefix(e, "while evaluating the file `%1%':\n", path2); throw; } + fileEvalCache[path2] = v; - //if (path != path2) fileEvalCache[path2] = v; + if (path != path2) fileEvalCache[path] = v; } |