From 182937fa27a95e561eaaa70cd8e054f95195501d Mon Sep 17 00:00:00 2001 From: Mike Pilgrem Date: Sat, 6 Apr 2024 19:09:21 +0100 Subject: [PATCH] Fix #6551 Use action `getLatestApplicableVersionAndRev` only when needed --- ChangeLog.md | 2 ++ src/Stack/Build/ConstructPlan.hs | 11 ++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 4619c58f04..1b73c0e3b3 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -56,6 +56,8 @@ Bug fixes: * The `config set snapshot` and `config set resolver` commands now respect the presence of a synoymous key. +* Fix a regression introduced in Stack 2.15.1 that caused a 'no operation' + `stack build` to be slower than previously. ## v2.15.5 - 2024-03-28 diff --git a/src/Stack/Build/ConstructPlan.hs b/src/Stack/Build/ConstructPlan.hs index 42092233f9..ef9f74474b 100644 --- a/src/Stack/Build/ConstructPlan.hs +++ b/src/Stack/Build/ConstructPlan.hs @@ -829,7 +829,6 @@ processDep :: MissingPresentDeps ) processDep pkgId name value = do - mLatestApplicable <- getLatestApplicableVersionAndRev name range eRes <- getCachedDepOrAddDep name let failure mLatestApp err = Left $ Map.singleton name (range, mLatestApp, err) @@ -844,6 +843,7 @@ processDep pkgId name value = do -- spamming the user too much. DependencyPlanFailures _ _ -> Couldn'tResolveItsDependencies version + mLatestApplicable <- getLatestApplicableVersionAndRev name range pure $ failure mLatestApplicable bd Right adr | isDepTypeLibrary value.depType && not (adrHasLibrary adr) -> @@ -851,10 +851,11 @@ processDep pkgId name value = do Right adr -> do addParent inRange <- adrInRange pkgId name range adr - pure $ if inRange - then Right $ processAdr adr - else failure mLatestApplicable (DependencyMismatch $ adrVersion adr) - + if inRange + then pure $ Right $ processAdr adr + else do + mLatestApplicable <- getLatestApplicableVersionAndRev name range + pure $ failure mLatestApplicable (DependencyMismatch $ adrVersion adr) where range = value.versionRange version = pkgVersion pkgId