mirror of
https://github.com/NixOS/nix.git
synced 2025-02-16 17:02:28 +00:00
functionArgs: Allocate bools only once
This commit is contained in:
parent
8c6e0df45f
commit
1fcdd1640e
@ -937,6 +937,9 @@ ListBuilder::ListBuilder(EvalState & state, size_t size)
|
||||
state.nrListElems += size;
|
||||
}
|
||||
|
||||
Value * EvalState::getBool(bool b) {
|
||||
return b ? &vTrue : &vFalse;
|
||||
}
|
||||
|
||||
unsigned long nrThunks = 0;
|
||||
|
||||
|
@ -650,6 +650,11 @@ public:
|
||||
return ListBuilder(*this, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a boolean `Value *` without allocating.
|
||||
*/
|
||||
Value *getBool(bool b);
|
||||
|
||||
void mkThunk_(Value & v, Expr * expr);
|
||||
void mkPos(Value & v, PosIdx pos);
|
||||
|
||||
|
@ -2845,8 +2845,7 @@ static void prim_functionArgs(EvalState & state, const PosIdx pos, Value * * arg
|
||||
|
||||
auto attrs = state.buildBindings(args[0]->lambda.fun->formals->formals.size());
|
||||
for (auto & i : args[0]->lambda.fun->formals->formals)
|
||||
// !!! should optimise booleans (allocate only once)
|
||||
attrs.alloc(i.name, i.pos).mkBool(i.def);
|
||||
attrs.insert(i.name, state.getBool(i.def), i.pos);
|
||||
v.mkAttrs(attrs);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user