diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-04-22T15·08+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-04-22T15·08+0000 |
commit | 0bc468f195e37a8a5f4f8b36ae6c92459e8ca652 (patch) | |
tree | f4057161b6bb181e2899dbe85816e68819327097 /src/libexpr/nixexpr.cc | |
parent | ee0384fb966b7a9bd202fa6fb447788be30c4ce4 (diff) |
* Simplify the implementation of `with'. This gives a 7% speedup in
evaluating the NixOS system configuration.
Diffstat (limited to 'src/libexpr/nixexpr.cc')
-rw-r--r-- | src/libexpr/nixexpr.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc index 3dfbddf5b89f..a9c83108e950 100644 --- a/src/libexpr/nixexpr.cc +++ b/src/libexpr/nixexpr.cc @@ -278,12 +278,12 @@ void ExprLet::bindVars(const StaticEnv & env) void ExprWith::bindVars(const StaticEnv & env) { /* Does this `with' have an enclosing `with'? If so, record its - level so that we can copy the attributes of the enclosing - `with'. */ + level so that `lookupVar' can look up variables in the previous + `with' if this one doesn't contain the desired attribute. */ const StaticEnv * curEnv; unsigned int level; - prevWith = -1; - for (curEnv = &env, level = 0; curEnv; curEnv = curEnv->up, level++) + prevWith = 0; + for (curEnv = &env, level = 1; curEnv; curEnv = curEnv->up, level++) if (curEnv->isWith) { prevWith = level; break; |