1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 13:21:47 +02:00

* 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).
This commit is contained in:
Eelco Dolstra 2010-01-25 17:18:44 +00:00
parent 50e34891f0
commit fdcaf37361
3 changed files with 13 additions and 41 deletions

View file

@ -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);
}

View file

@ -19,7 +19,8 @@ Derivation derivationFromPath(const Path & drvPath);
`referrers' relation instead of the `references' relation is
returned. */
void computeFSClosure(const Path & storePath,
PathSet & paths, bool flipDirection = false);
PathSet & paths, bool flipDirection = false,
bool includeOutputs = false);
/* Return the path corresponding to the output identifier `id' in the
given derivation. */