Try to cut recursion depth in uniqList and closePropagation.

This commit is contained in:
Andres Loeh 2012-07-18 11:18:15 +02:00
parent 83505f15b2
commit 3fbd694d7d

View File

@ -158,14 +158,15 @@ rec {
(tail x))))) condList)) ; (tail x))))) condList)) ;
# !!! This function has O(n^2) performance, so you probably don't want to use it! # This function has O(n^2) performance.
uniqList = {inputList, outputList ? []}: uniqList = {inputList, acc ? []} :
if (inputList == []) then outputList else let go = xs : acc :
let x=head inputList; if xs == []
newOutputList = outputList ++ then []
(if elem x outputList then [] else [x]); else let x = head xs;
in uniqList {outputList=newOutputList; y = if elem x acc then [] else [x];
inputList = (tail inputList);}; in go (y ++ tail xs) (y ++ acc);
in go inputList acc;
uniqListExt = {inputList, outputList ? [], uniqListExt = {inputList, outputList ? [],
getter ? (x : x), compare ? (x: y: x==y)}: getter ? (x : x), compare ? (x: y: x==y)}:
@ -214,16 +215,22 @@ rec {
modifySumArgs = f: x: innerModifySumArgs f x {}; modifySumArgs = f: x: innerModifySumArgs f x {};
innerClosePropagation = ready: list: if list == [] then ready else innerClosePropagation = acc : xs :
if ! isAttrs (head list) then if xs == []
/* builtins.trace ("not an attrSet: ${lib.showVal (head list)}") */ then acc
innerClosePropagation ready (tail list) else let y = head xs;
else ys = tail xs;
innerClosePropagation in if ! isAttrs y
(ready ++ [(head list)]) then innerClosePropagation acc ys
((tail list) else let acc' = [y] ++ acc;
++ (maybeAttrNullable "propagatedBuildInputs" [] (head list)) in innerClosePropagation
++ (maybeAttrNullable "propagatedBuildNativeInputs" [] (head list))); acc'
(uniqList { inputList = (maybeAttrNullable "propagatedBuildInputs" [] y)
++ (maybeAttrNullable "propagatedBuildNativeInputs" [] y)
++ ys;
acc = acc';
}
);
closePropagation = list: (uniqList {inputList = (innerClosePropagation [] list);}); closePropagation = list: (uniqList {inputList = (innerClosePropagation [] list);});