mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 09:06:15 +02:00
* Fix the atrocious (exponential? factorial?) time complexity in
`nix --query --requisites'.
This commit is contained in:
parent
920193beb1
commit
31be53cd0a
1 changed files with 9 additions and 4 deletions
|
@ -321,8 +321,12 @@ Strings fstatePaths(const FSId & id)
|
|||
|
||||
|
||||
static void fstateRequisitesSet(const FSId & id,
|
||||
bool includeExprs, bool includeSuccessors, StringSet & paths)
|
||||
bool includeExprs, bool includeSuccessors, StringSet & paths,
|
||||
FSIdSet & doneSet)
|
||||
{
|
||||
if (doneSet.find(id) != doneSet.end()) return;
|
||||
doneSet.insert(id);
|
||||
|
||||
FState fs = parseFState(termFromId(id));
|
||||
|
||||
if (fs.type == FState::fsSlice)
|
||||
|
@ -334,7 +338,7 @@ static void fstateRequisitesSet(const FSId & id,
|
|||
for (FSIdSet::iterator i = fs.derive.inputs.begin();
|
||||
i != fs.derive.inputs.end(); i++)
|
||||
fstateRequisitesSet(*i,
|
||||
includeExprs, includeSuccessors, paths);
|
||||
includeExprs, includeSuccessors, paths, doneSet);
|
||||
|
||||
else abort();
|
||||
|
||||
|
@ -345,7 +349,7 @@ static void fstateRequisitesSet(const FSId & id,
|
|||
if (includeSuccessors &&
|
||||
nixDB.queryString(noTxn, dbSuccessors, id, idSucc))
|
||||
fstateRequisitesSet(parseHash(idSucc),
|
||||
includeExprs, includeSuccessors, paths);
|
||||
includeExprs, includeSuccessors, paths, doneSet);
|
||||
}
|
||||
|
||||
|
||||
|
@ -353,7 +357,8 @@ Strings fstateRequisites(const FSId & id,
|
|||
bool includeExprs, bool includeSuccessors)
|
||||
{
|
||||
StringSet paths;
|
||||
fstateRequisitesSet(id, includeExprs, includeSuccessors, paths);
|
||||
FSIdSet doneSet;
|
||||
fstateRequisitesSet(id, includeExprs, includeSuccessors, paths, doneSet);
|
||||
return Strings(paths.begin(), paths.end());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue