* Cache parse trees to prevent repeated parsing of imported Nix
expressions.
This commit is contained in:
parent
3d94be61ea
commit
55e207b2dc
|
@ -272,7 +272,14 @@ void EvalState::cloneAttrs(Value & src, Value & dst)
|
||||||
void EvalState::evalFile(const Path & path, Value & v)
|
void EvalState::evalFile(const Path & path, Value & v)
|
||||||
{
|
{
|
||||||
startNest(nest, lvlTalkative, format("evaluating file `%1%'") % path);
|
startNest(nest, lvlTalkative, format("evaluating file `%1%'") % path);
|
||||||
Expr e = parseExprFromFile(*this, path);
|
|
||||||
|
Expr e = parseTrees.get(toATerm(path));
|
||||||
|
|
||||||
|
if (!e) {
|
||||||
|
e = parseExprFromFile(*this, path);
|
||||||
|
parseTrees.set(toATerm(path), e);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
eval(e, v);
|
eval(e, v);
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
|
|
|
@ -135,6 +135,8 @@ private:
|
||||||
|
|
||||||
bool allowUnsafeEquality;
|
bool allowUnsafeEquality;
|
||||||
|
|
||||||
|
ATermMap parseTrees;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EvalState();
|
EvalState();
|
||||||
|
|
|
@ -526,12 +526,6 @@ Expr parseExprFromFile(EvalState & state, Path path)
|
||||||
{
|
{
|
||||||
assert(path[0] == '/');
|
assert(path[0] == '/');
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Perhaps this is already an imploded parse tree? */
|
|
||||||
Expr e = ATreadFromNamedFile(path.c_str());
|
|
||||||
if (e) return e;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* If `path' is a symlink, follow it. This is so that relative
|
/* If `path' is a symlink, follow it. This is so that relative
|
||||||
path references work. */
|
path references work. */
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
Loading…
Reference in a new issue