about summary refs log tree commit diff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-09-03T10·56+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-09-03T11·01+0200
commit6f809194d7448c4ad50174bed9ba2419e2114352 (patch)
tree03e493977baf95671cb652b197772376c68fe130 /src/libexpr/eval.cc
parent57d18df7d0005cf822368d9f1d0c33396c6b9f9f (diff)
Get rid of the parse tree cache
Since we already cache files in normal form (fileEvalCache), caching
parse trees is redundant.

Note that getting rid of this cache doesn't actually save much memory
at the moment, because parse trees are currently not freed / GC'ed.
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 6ac07eed6c..50f36ce4e9 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -440,26 +440,30 @@ Value * ExprPath::maybeThunk(EvalState & state, Env & env)
 
 void EvalState::evalFile(const Path & path, Value & v)
 {
-    FileEvalCache::iterator i = fileEvalCache.find(path);
-    if (i == fileEvalCache.end()) {
-        startNest(nest, lvlTalkative, format("evaluating file `%1%'") % path);
-        Expr * e = parseExprFromFile(path);
-        try {
-            eval(e, v);
-        } catch (Error & e) {
-            addErrorPrefix(e, "while evaluating the file `%1%':\n", path);
-            throw;
-        }
-        fileEvalCache[path] = v;
-    } else
+    Path path2 = resolveExprPath(path);
+
+    FileEvalCache::iterator i = fileEvalCache.find(path2);
+    if (i != fileEvalCache.end()) {
         v = i->second;
+        return;
+    }
+
+    startNest(nest, lvlTalkative, format("evaluating file `%1%'") % path2);
+    Expr * e = parseExprFromFile(path2);
+    try {
+        eval(e, v);
+    } catch (Error & e) {
+        addErrorPrefix(e, "while evaluating the file `%1%':\n", path2);
+        throw;
+    }
+    fileEvalCache[path2] = v;
+    //if (path != path2) fileEvalCache[path2] = v;
 }
 
 
 void EvalState::resetFileCache()
 {
     fileEvalCache.clear();
-    parseTrees.clear();
 }