1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-26 07:31:15 +02:00

Cache parse trees

This prevents EvalState::resetFileCache() from parsing everything all
over again.
This commit is contained in:
Eelco Dolstra 2018-06-11 16:06:01 +02:00
parent 6ad0a2f749
commit 24c6806994
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
2 changed files with 19 additions and 2 deletions

View file

@ -332,7 +332,6 @@ EvalState::EvalState(const Strings & _searchPath, ref<Store> store)
EvalState::~EvalState()
{
fileEvalCache.clear();
}
@ -711,7 +710,17 @@ void EvalState::evalFile(const Path & path_, Value & v)
}
printTalkative("evaluating file '%1%'", path2);
Expr * e = parseExprFromFile(checkSourcePath(path2));
Expr * e = nullptr;
auto j = fileParseCache.find(path2);
if (j != fileParseCache.end())
e = j->second;
if (!e)
e = parseExprFromFile(checkSourcePath(path2));
fileParseCache[path2] = e;
try {
eval(e, v);
} catch (Error & e) {