From 26003911478a62a6c5f258ad8c1331c3d0bd876d Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 13 Aug 2025 22:25:41 -0400 Subject: [PATCH] Simplify `DerivationGoal` loop -> if More taking advantage of single wanted output. Also `auto *` not `auto` for easy reading. --- src/libstore/build/derivation-goal.cc | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc index c65dbda21..c791aa5fc 100644 --- a/src/libstore/build/derivation-goal.cc +++ b/src/libstore/build/derivation-goal.cc @@ -126,23 +126,18 @@ Goal::Co DerivationGoal::haveDerivation() experimentalFeatureSettings.require(Xp::ImpureDerivations); auto outputHashes = staticOutputHashes(worker.evalStore, *drv); - for (auto & [outputName, outputHash] : outputHashes) { - if (outputName != wantedOutput) - continue; - - this->outputHash = outputHash; + if (auto * mOutputHash = get(outputHashes, wantedOutput)) { + outputHash = *mOutputHash; /* TODO we might want to also allow randomizing the paths for regular CA derivations, e.g. for sake of checking determinism. */ if (impure) { outputKnown = InitialOutputStatus{ - .path = StorePath::random(outputPathName(drv->name, outputName)), + .path = StorePath::random(outputPathName(drv->name, wantedOutput)), .status = PathStatus::Absent, }; } - - break; } if (impure) { @@ -247,7 +242,7 @@ Goal::Co DerivationGoal::repairClosure() }(); StorePathSet outputClosure; - if (auto mPath = get(outputs, wantedOutput)) { + if (auto * mPath = get(outputs, wantedOutput)) { worker.store.computeFSClosure(*mPath, outputClosure); }