From fdcaf37361126793a1416ef5b348e5bf2f0fd1a0 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 25 Jan 2010 17:18:44 +0000 Subject: * Made `nix-store -qR --include-outputs' much faster if there are multiple paths specified on the command line (from O(n * m) to O(n + m), where n is the number of arguments and m is the size of the closure). --- src/libstore/misc.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/libstore/misc.cc') diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc index f2b4c7a4ee60..2d7d13a0e7b4 100644 --- a/src/libstore/misc.cc +++ b/src/libstore/misc.cc @@ -19,7 +19,7 @@ Derivation derivationFromPath(const Path & drvPath) void computeFSClosure(const Path & storePath, - PathSet & paths, bool flipDirection) + PathSet & paths, bool flipDirection, bool includeOutputs) { if (paths.find(storePath) != paths.end()) return; paths.insert(storePath); @@ -30,8 +30,15 @@ void computeFSClosure(const Path & storePath, else store->queryReferences(storePath, references); + if (includeOutputs && isDerivation(storePath)) { + Derivation drv = derivationFromPath(storePath); + foreach (DerivationOutputs::iterator, i, drv.outputs) + if (store->isValidPath(i->second.path)) + computeFSClosure(i->second.path, paths, flipDirection, true); + } + foreach (PathSet::iterator, i, references) - computeFSClosure(*i, paths, flipDirection); + computeFSClosure(*i, paths, flipDirection, includeOutputs); } -- cgit 1.4.1