From 4fa9d48fd47df45372fddf2251c3fc0afd48fda0 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 16 Feb 2021 21:46:18 +0100 Subject: gexp: 'gexp-inputs' returns both native and non-native inputs. This avoids double traversal of references and extra bookkeeping, thereby further reducing memory allocations. * guix/gexp.scm (lower-gexp): Include only one call to 'lower-inputs'. (gexp-inputs): Remove #:native? parameter. [set-gexp-input-native?]: New procedure. [add-reference-inputs]: Use it. (gexp-native-inputs): Remove. * tests/gexp.scm (gexp-native-inputs): Remove. (gexp-input->tuple): Include 'gexp-input-native?'. ("let-system") ("let-system, nested") ("ungexp + ungexp-native") ("ungexp + ungexp-native, nested") ("ungexp + ungexp-native, nested, special mixture") ("input list") ("input list + ungexp-native") ("input list splicing") ("input list splicing + ungexp-native-splicing") ("gexp list splicing + ungexp-splicing"): Adjust accordingly. --- guix/gexp.scm | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) (limited to 'guix') diff --git a/guix/gexp.scm b/guix/gexp.scm index 8e80d4adbe..7a3228ec2e 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -1006,13 +1006,9 @@ derivations--e.g., code evaluated for its side effects." (guile (if guile-for-build (return guile-for-build) (default-guile-derivation system))) - (normals (lower-inputs (gexp-inputs exp) + (inputs (lower-inputs (gexp-inputs exp) #:system system #:target target)) - (natives (lower-inputs (gexp-native-inputs exp) - #:system system - #:target #f)) - (inputs -> (append normals natives)) (sexp (gexp->sexp exp #:system system #:target target)) @@ -1218,26 +1214,26 @@ The other arguments are as for 'derivation'." #:substitutable? substitutable? #:properties properties)))) -(define* (gexp-inputs exp #:key native?) - "Return the list of for EXP. When NATIVE? is true, return only -native references; otherwise, return only non-native references." +(define (gexp-inputs exp) + "Return the list of for EXP." + (define set-gexp-input-native? + (match-lambda + (($ thing output) + (%gexp-input thing output #t)))) + (define (add-reference-inputs ref result) (match ref (($ (? gexp? exp) _ #t) - (if native? - (append (gexp-inputs exp) - (gexp-inputs exp #:native? #t) - result) - result)) - (($ (? gexp? exp) _ #f) - (append (gexp-inputs exp #:native? native?) + (append (map set-gexp-input-native? (gexp-inputs exp)) result)) + (($ (? gexp? exp) _ #f) + (append (gexp-inputs exp) result)) (($ (? string? str)) (if (direct-store-path? str) (cons ref result) result)) (($ (? struct? thing) output n?) - (if (and (eqv? n? native?) (lookup-compiler thing)) + (if (lookup-compiler thing) ;; THING is a derivation, or a package, or an origin, etc. (cons ref result) result)) @@ -1261,9 +1257,6 @@ native references; otherwise, return only non-native references." '() (gexp-references exp))) -(define gexp-native-inputs - (cut gexp-inputs <> #:native? #t)) - (define (gexp-outputs exp) "Return the outputs referred to by EXP as a list of strings." (define (add-reference-output ref result) -- cgit v1.2.3