mirror of
https://github.com/NixOS/nix
synced 2025-06-28 01:11:15 +02:00
Optimize empty sets
This reduces the number of Bindings allocations by about 10%.
This commit is contained in:
parent
16c9935fa9
commit
c8bb2371eb
3 changed files with 14 additions and 4 deletions
|
@ -29,13 +29,17 @@ Bindings * EvalState::allocBindings(Bindings::size_t capacity)
|
|||
}
|
||||
|
||||
|
||||
void EvalState::mkAttrs(Value & v, unsigned int expected)
|
||||
void EvalState::mkAttrs(Value & v, unsigned int capacity)
|
||||
{
|
||||
if (capacity == 0) {
|
||||
v = vEmptySet;
|
||||
return;
|
||||
}
|
||||
clearValue(v);
|
||||
v.type = tAttrs;
|
||||
v.attrs = allocBindings(expected);
|
||||
v.attrs = allocBindings(capacity);
|
||||
nrAttrsets++;
|
||||
nrAttrsInAttrsets += expected;
|
||||
nrAttrsInAttrsets += capacity;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue