aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2016-10-07 19:57:47 +0200
committerEelco Dolstra <edolstra@gmail.com>2016-10-07 19:57:47 +0200
commitedf9eb8181e01f6b2123e5690019cfeeb44fc1c2 (patch)
tree68ffd81d207a40d7909d79da9baf76f27c2c391d /src/libstore
parent0c85ef7090898a9152c2a6fd31633aa7fc8550b3 (diff)
querySubstitutablePaths(): Don't query paths for which we already have a substituter
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/local-store.cc19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 41e1c37a0..4f2c433b8 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -781,14 +781,27 @@ Path LocalStore::queryPathFromHashPart(const string & hashPart)
PathSet LocalStore::querySubstitutablePaths(const PathSet & paths)
{
if (!settings.useSubstitutes) return PathSet();
+
+ auto remaining = paths;
PathSet res;
+
for (auto & sub : getDefaultSubstituters()) {
- if (res.size() == paths.size()) break;
+ if (remaining.empty()) break;
if (sub->storeDir != storeDir) continue;
if (!sub->wantMassQuery()) continue;
- for (auto path : sub->queryValidPaths(paths))
- res.insert(path);
+
+ auto valid = sub->queryValidPaths(remaining);
+
+ PathSet remaining2;
+ for (auto & path : remaining)
+ if (valid.count(path))
+ res.insert(path);
+ else
+ remaining2.insert(path);
+
+ std::swap(remaining, remaining2);
}
+
return res;
}