diff --git a/guix/derivations.scm b/guix/derivations.scm index 2fe684cc18..33f4dc5d9d 100644 --- a/guix/derivations.scm +++ b/guix/derivations.scm @@ -241,32 +241,29 @@ the store." "Return a list of inputs, such that when INPUTS contains the same DRV twice, they are coalesced, with their sub-derivations merged. This is needed because Nix itself keeps only one of them." - (define (find pred lst) ;inlinable copy of 'find' - (let loop ((lst lst)) - (match lst - (() #f) - ((head . tail) - (if (pred head) head (loop tail)))))) + (define table + (make-hash-table 25)) - (fold (lambda (input result) - (match input - (($ (= derivation-file-name path) sub-drvs) - ;; XXX: quadratic - (match (find (match-lambda - (($ (= derivation-file-name p) - s) - (string=? p path))) - result) - (#f - (cons input result)) - ((and dup ($ drv sub-drvs2)) - ;; Merge DUP with INPUT. - (let ((sub-drvs (delete-duplicates - (append sub-drvs sub-drvs2)))) - (cons (make-derivation-input drv (sort sub-drvs string drv sub-drvs2))) + ;; Merge DUP with INPUT. + (let* ((sub-drvs (delete-duplicates + (append sub-drvs sub-drvs2))) + (input + (make-derivation-input drv + (sort sub-drvs string