* Caching of parse results for fairer comparisons.

This commit is contained in:
Eelco Dolstra committed 2007-10-11 20:02:08 +00:00
1 parent c1179badd5
commit cd9d10d4e3
2 files changed
+8 -1

No files matched your search

+2
View File
@@ -41,6 +41,8 @@ struct EvalState
bool cacheTerms;
bool strictMode;
ATermMap parsings; /* path -> expr mapping */
EvalState();
void addPrimOps();
+6 -1
View File
@@ -383,8 +383,13 @@ Expr parseExprFromFile(EvalState & state, Path path)
if (S_ISDIR(st.st_mode))
path = canonPath(path + "/default.nix");
Expr cached = state.parsings.get(toATerm(path));
if (cached) return cached;
/* Read and parse the input file. */
return parse(state, readFile(path).c_str(), path, dirOf(path));
cached = parse(state, readFile(path).c_str(), path, dirOf(path));
state.parsings.set(toATerm(path), cached);
return cached;
}