forked from lix-project/lix
Optimize empty sets
This reduces the number of Bindings allocations by about 10%.
This commit is contained in:
parent
16c9935fa9
commit
c8bb2371eb
|
@ -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);
|
clearValue(v);
|
||||||
v.type = tAttrs;
|
v.type = tAttrs;
|
||||||
v.attrs = allocBindings(expected);
|
v.attrs = allocBindings(capacity);
|
||||||
nrAttrsets++;
|
nrAttrsets++;
|
||||||
nrAttrsInAttrsets += expected;
|
nrAttrsInAttrsets += capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -281,6 +281,10 @@ EvalState::EvalState(const Strings & _searchPath)
|
||||||
for (auto & i : paths) addToSearchPath(i);
|
for (auto & i : paths) addToSearchPath(i);
|
||||||
addToSearchPath("nix=" + settings.nixDataDir + "/nix/corepkgs");
|
addToSearchPath("nix=" + settings.nixDataDir + "/nix/corepkgs");
|
||||||
|
|
||||||
|
clearValue(vEmptySet);
|
||||||
|
vEmptySet.type = tAttrs;
|
||||||
|
vEmptySet.attrs = allocBindings(0);
|
||||||
|
|
||||||
createBaseEnv();
|
createBaseEnv();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,8 @@ public:
|
||||||
path or to environment variables. */
|
path or to environment variables. */
|
||||||
bool restricted;
|
bool restricted;
|
||||||
|
|
||||||
|
Value vEmptySet;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SrcToStore srcToStore;
|
SrcToStore srcToStore;
|
||||||
|
|
||||||
|
@ -227,7 +229,7 @@ public:
|
||||||
Bindings * allocBindings(Bindings::size_t capacity);
|
Bindings * allocBindings(Bindings::size_t capacity);
|
||||||
|
|
||||||
void mkList(Value & v, unsigned int length);
|
void mkList(Value & v, unsigned int length);
|
||||||
void mkAttrs(Value & v, unsigned int expected);
|
void mkAttrs(Value & v, unsigned int capacity);
|
||||||
void mkThunk_(Value & v, Expr * expr);
|
void mkThunk_(Value & v, Expr * expr);
|
||||||
void mkPos(Value & v, Pos * pos);
|
void mkPos(Value & v, Pos * pos);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue