guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/06: packages: Optimize 'package-transitive-supported-systems'.


From: Ludovic Courtès
Subject: 01/06: packages: Optimize 'package-transitive-supported-systems'.
Date: Mon, 2 Jul 2018 18:39:20 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 24420f5ffabfbdbe913a5765e5c00e17de18fb4c
Author: Ludovic Courtès <address@hidden>
Date:   Mon Jul 2 22:15:35 2018 +0200

    packages: Optimize 'package-transitive-supported-systems'.
    
    This version is 13% faster than the one above when timing:
    
      (fold-packages (lambda (p x)
                   (package-transitive-supported-systems p))
                 '())
    
    * guix/packages.scm (package-transitive-supported-systems): Make
    'systems' a set instead of calling 'lset-intersection' repeatedly.
---
 guix/packages.scm | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/guix/packages.scm b/guix/packages.scm
index c762fa7..cd7d3b8 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -766,15 +766,16 @@ in INPUTS and their transitive propagated inputs."
   (mlambdaq (package)
     "Return the intersection of the systems supported by PACKAGE and those
 supported by its dependencies."
-    (fold (lambda (input systems)
-            (match input
-              ((label (? package? p) . _)
-               (lset-intersection
-                string=? systems (package-transitive-supported-systems p)))
-              (_
-               systems)))
-          (package-supported-systems package)
-          (bag-direct-inputs (package->bag package)))))
+    (set->list
+     (fold (lambda (input systems)
+             (match input
+               ((label (? package? p) . _)
+                (fold set-insert systems
+                      (package-transitive-supported-systems p)))
+               (_
+                systems)))
+           (list->set (package-supported-systems package))
+           (bag-direct-inputs (package->bag package))))))
 
 (define* (supported-package? package #:optional (system (%current-system)))
   "Return true if PACKAGE is supported on SYSTEM--i.e., if PACKAGE and all its



reply via email to

[Prev in Thread] Current Thread [Next in Thread]