mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
Merge pull request #9681 from edolstra/eval-optimisations
Optimize empty list constants
This commit is contained in:
commit
315aade89d
3 changed files with 17 additions and 0 deletions
|
@ -554,6 +554,8 @@ EvalState::EvalState(
|
|||
|
||||
static_assert(sizeof(Env) <= 16, "environment must be <= 16 bytes");
|
||||
|
||||
vEmptyList.mkList(0);
|
||||
|
||||
/* Initialise the Nix expression search path. */
|
||||
if (!evalSettings.pureEval) {
|
||||
for (auto & i : _searchPath.elements)
|
||||
|
@ -1385,6 +1387,15 @@ void ExprList::eval(EvalState & state, Env & env, Value & v)
|
|||
}
|
||||
|
||||
|
||||
Value * ExprList::maybeThunk(EvalState & state, Env & env)
|
||||
{
|
||||
if (elems.empty()) {
|
||||
return &state.vEmptyList;
|
||||
}
|
||||
return Expr::maybeThunk(state, env);
|
||||
}
|
||||
|
||||
|
||||
void ExprVar::eval(EvalState & state, Env & env, Value & v)
|
||||
{
|
||||
Value * v2 = state.lookupVar(&env, *this, false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue