mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 15:26:17 +02:00
remove lazy-pos forceValue
almost all uses of this are interactive, except for deepSeq. deepSeq is going to be expensive and rare enough to not care much about, and Value::determinePos should usually be cheap enough to not be too much of a burden in any case.
This commit is contained in:
parent
f9aee2f2c4
commit
69ed4aee61
9 changed files with 10 additions and 21 deletions
|
@ -52,7 +52,7 @@ Value * InstallableFlake::getFlakeOutputs(EvalState & state, const flake::Locked
|
|||
auto aOutputs = vFlake->attrs->get(state.symbols.create("outputs"));
|
||||
assert(aOutputs);
|
||||
|
||||
state.forceValue(*aOutputs->value, [&]() { return aOutputs->value->determinePos(noPos); });
|
||||
state.forceValue(*aOutputs->value, aOutputs->value->determinePos(noPos));
|
||||
|
||||
return aOutputs->value;
|
||||
}
|
||||
|
|
|
@ -888,7 +888,7 @@ void NixRepl::evalString(std::string s, Value & v)
|
|||
{
|
||||
Expr * e = parseString(s);
|
||||
e->eval(*state, *env, v);
|
||||
state->forceValue(v, [&]() { return v.determinePos(noPos); });
|
||||
state->forceValue(v, v.determinePos(noPos));
|
||||
}
|
||||
|
||||
|
||||
|
@ -907,7 +907,7 @@ std::ostream & NixRepl::printValue(std::ostream & str, Value & v, unsigned int m
|
|||
str.flush();
|
||||
checkInterrupt();
|
||||
|
||||
state->forceValue(v, [&]() { return v.determinePos(noPos); });
|
||||
state->forceValue(v, v.determinePos(noPos));
|
||||
|
||||
switch (v.type()) {
|
||||
|
||||
|
|
|
@ -81,15 +81,7 @@ Env & EvalState::allocEnv(size_t size)
|
|||
}
|
||||
|
||||
|
||||
[[gnu::always_inline]]
|
||||
void EvalState::forceValue(Value & v, const PosIdx pos)
|
||||
{
|
||||
forceValue(v, [&]() { return pos; });
|
||||
}
|
||||
|
||||
|
||||
template<typename Callable>
|
||||
void EvalState::forceValue(Value & v, Callable getPos)
|
||||
{
|
||||
if (v.isThunk()) {
|
||||
Env * env = v.thunk.env;
|
||||
|
@ -110,7 +102,7 @@ void EvalState::forceValue(Value & v, Callable getPos)
|
|||
// only one black hole can *throw* in any given eval stack so we need not
|
||||
// check whether the position is set already.
|
||||
if (v.isBlackhole())
|
||||
e.err.errPos = positions[getPos()];
|
||||
e.err.errPos = positions[pos];
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2044,7 +2044,7 @@ void EvalState::forceValueDeep(Value & v)
|
|||
recurse = [&](Value & v) {
|
||||
if (!seen.insert(&v).second) return;
|
||||
|
||||
forceValue(v, [&]() { return v.determinePos(noPos); });
|
||||
forceValue(v, v.determinePos(noPos));
|
||||
|
||||
if (v.type() == nAttrs) {
|
||||
for (auto & i : *v.attrs)
|
||||
|
|
|
@ -473,9 +473,6 @@ public:
|
|||
*/
|
||||
inline void forceValue(Value & v, const PosIdx pos);
|
||||
|
||||
template <typename Callable>
|
||||
inline void forceValue(Value & v, Callable getPos);
|
||||
|
||||
/**
|
||||
* Force a value, then recursively force list elements and
|
||||
* attributes.
|
||||
|
|
|
@ -198,7 +198,7 @@ StringSet DrvInfo::queryMetaNames()
|
|||
|
||||
bool DrvInfo::checkMeta(Value & v)
|
||||
{
|
||||
state->forceValue(v, [&]() { return v.determinePos(noPos); });
|
||||
state->forceValue(v, v.determinePos(noPos));
|
||||
if (v.type() == nList) {
|
||||
for (auto elem : v.listItems())
|
||||
if (!checkMeta(*elem)) return false;
|
||||
|
@ -304,7 +304,7 @@ static bool getDerivation(EvalState & state, Value & v,
|
|||
bool ignoreAssertionFailures)
|
||||
{
|
||||
try {
|
||||
state.forceValue(v, [&]() { return v.determinePos(noPos); });
|
||||
state.forceValue(v, v.determinePos(noPos));
|
||||
if (!state.isDerivation(v)) return true;
|
||||
|
||||
/* Remove spurious duplicates (e.g., a set like `rec { x =
|
||||
|
|
|
@ -350,7 +350,7 @@ static void main_nix_build(int argc, char * * argv)
|
|||
takesNixShellAttr(vRoot) ? *autoArgsWithInNixShell : *autoArgs,
|
||||
vRoot
|
||||
).first);
|
||||
state->forceValue(v, [&]() { return v.determinePos(noPos); });
|
||||
state->forceValue(v, v.determinePos(noPos));
|
||||
getDerivations(
|
||||
*state,
|
||||
v,
|
||||
|
|
|
@ -128,7 +128,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
|||
|
||||
/* Evaluate it. */
|
||||
debug("evaluating user environment builder");
|
||||
state.forceValue(topLevel, [&]() { return topLevel.determinePos(noPos); });
|
||||
state.forceValue(topLevel, topLevel.determinePos(noPos));
|
||||
NixStringContext context;
|
||||
Attr & aDrvPath(*topLevel.attrs->find(state.sDrvPath));
|
||||
auto topLevelDrv = state.coerceToStorePath(aDrvPath.pos, *aDrvPath.value, context, "");
|
||||
|
|
|
@ -40,7 +40,7 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
|||
|
||||
for (auto & i : attrPaths) {
|
||||
Value & v(*findAlongAttrPath(state, i, autoArgs, vRoot).first);
|
||||
state.forceValue(v, [&]() { return v.determinePos(noPos); });
|
||||
state.forceValue(v, v.determinePos(noPos));
|
||||
|
||||
NixStringContext context;
|
||||
if (evalOnly) {
|
||||
|
|
Loading…
Reference in a new issue