summaryrefslogtreecommitdiff
path: root/guix/gexp.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-02-16 21:46:18 +0100
committerLudovic Courtès <ludo@gnu.org>2021-02-23 15:24:48 +0100
commit4fa9d48fd47df45372fddf2251c3fc0afd48fda0 (patch)
tree251c7bcac03efdb64254f304d0fc2b72651637b1 /guix/gexp.scm
parentfc6d6aee6659acb293eb33f498fdac3b47a19a48 (diff)
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.
Diffstat (limited to 'guix/gexp.scm')
-rw-r--r--guix/gexp.scm31
1 files changed, 12 insertions, 19 deletions
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 <gexp-input> for EXP. When NATIVE? is true, return only
-native references; otherwise, return only non-native references."
+(define (gexp-inputs exp)
+ "Return the list of <gexp-input> for EXP."
+ (define set-gexp-input-native?
+ (match-lambda
+ (($ <gexp-input> thing output)
+ (%gexp-input thing output #t))))
+
(define (add-reference-inputs ref result)
(match ref
(($ <gexp-input> (? gexp? exp) _ #t)
- (if native?
- (append (gexp-inputs exp)
- (gexp-inputs exp #:native? #t)
- result)
- result))
- (($ <gexp-input> (? gexp? exp) _ #f)
- (append (gexp-inputs exp #:native? native?)
+ (append (map set-gexp-input-native? (gexp-inputs exp))
result))
+ (($ <gexp-input> (? gexp? exp) _ #f)
+ (append (gexp-inputs exp) result))
(($ <gexp-input> (? string? str))
(if (direct-store-path? str)
(cons ref result)
result))
(($ <gexp-input> (? 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)