forked from lix-project/lix
Cache parse trees
This prevents EvalState::resetFileCache() from parsing everything all over again.
This commit is contained in:
parent
6ad0a2f749
commit
24c6806994
|
@ -332,7 +332,6 @@ EvalState::EvalState(const Strings & _searchPath, ref<Store> store)
|
||||||
|
|
||||||
EvalState::~EvalState()
|
EvalState::~EvalState()
|
||||||
{
|
{
|
||||||
fileEvalCache.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -711,7 +710,17 @@ void EvalState::evalFile(const Path & path_, Value & v)
|
||||||
}
|
}
|
||||||
|
|
||||||
printTalkative("evaluating file '%1%'", path2);
|
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 {
|
try {
|
||||||
eval(e, v);
|
eval(e, v);
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
|
|
|
@ -90,6 +90,14 @@ public:
|
||||||
private:
|
private:
|
||||||
SrcToStore srcToStore;
|
SrcToStore srcToStore;
|
||||||
|
|
||||||
|
/* A cache from path names to parse trees. */
|
||||||
|
#if HAVE_BOEHMGC
|
||||||
|
typedef std::map<Path, Expr *, std::less<Path>, traceable_allocator<std::pair<const Path, Expr *> > > FileParseCache;
|
||||||
|
#else
|
||||||
|
typedef std::map<Path, Expr *> FileParseCache;
|
||||||
|
#endif
|
||||||
|
FileParseCache fileParseCache;
|
||||||
|
|
||||||
/* A cache from path names to values. */
|
/* A cache from path names to values. */
|
||||||
#if HAVE_BOEHMGC
|
#if HAVE_BOEHMGC
|
||||||
typedef std::map<Path, Value, std::less<Path>, traceable_allocator<std::pair<const Path, Value> > > FileEvalCache;
|
typedef std::map<Path, Value, std::less<Path>, traceable_allocator<std::pair<const Path, Value> > > FileEvalCache;
|
||||||
|
|
Loading…
Reference in a new issue