[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
14/20: gexp: Reduce allocations in 'gexp-attribute'.
From: |
guix-commits |
Subject: |
14/20: gexp: Reduce allocations in 'gexp-attribute'. |
Date: |
Mon, 1 Mar 2021 09:32:11 -0500 (EST) |
civodul pushed a commit to branch wip-build-systems-gexp
in repository guix.
commit ca707020670f6a78642e3153aa17cdabf465fc19
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Tue Feb 23 14:19:48 2021 +0100
gexp: Reduce allocations in 'gexp-attribute'.
* guix/gexp.scm (gexp-attribute): Use 'fold' and 'fold/tree' instead of
'append-map'.
---
guix/gexp.scm | 35 ++++++++++++++++++++++-------------
1 file changed, 22 insertions(+), 13 deletions(-)
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 8f49a0b..bab964a 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -759,19 +759,28 @@ attribute that is traversed."
(append (let ((attribute (self-attribute gexp)))
(validate gexp attribute)
attribute)
- (append-map (match-lambda
- (($ <gexp-input> (? gexp? exp))
- (gexp-attribute exp self-attribute
- #:validate validate))
- (($ <gexp-input> (lst ...))
- (append-map (lambda (item)
- (gexp-attribute item self-attribute
- #:validate
- validate))
- lst))
- (_
- '()))
- (gexp-references gexp)))
+ (reverse
+ (fold (lambda (input result)
+ (match input
+ (($ <gexp-input> (? gexp? exp))
+ (append (gexp-attribute exp self-attribute
+ #:validate validate)
+ result))
+ (($ <gexp-input> (lst ...))
+ (fold/tree (lambda (obj result)
+ (match obj
+ ((? gexp? exp)
+ (append (gexp-attribute exp
self-attribute
+ #:validate
validate)
+ result))
+ (_
+ result)))
+ result
+ lst))
+ (_
+ result)))
+ '()
+ (gexp-references gexp))))
equal?)
'())) ;plain Scheme data type
- 12/20: grafts: Inline 'grafting?' and 'set-grafting'., (continued)
- 12/20: grafts: Inline 'grafting?' and 'set-grafting'., guix-commits, 2021/03/01
- 15/20: serialization: Micro-optimize string literal output in 'write-file-tree'., guix-commits, 2021/03/01
- 16/20: gexp: Optimize 'with-build-variables'., guix-commits, 2021/03/01
- 17/20: packages: Default origin 'patch-flags' is a gexp., guix-commits, 2021/03/01
- 18/20: gexp: Add 'sexp->gexp'., guix-commits, 2021/03/01
- 08/20: gexp: Keep 'lower-inputs' private., guix-commits, 2021/03/01
- 10/20: store: Object cache profiling shows the number of entries., guix-commits, 2021/03/01
- 11/20: gexp: Reduce allocations while traversing lists., guix-commits, 2021/03/01
- 06/20: gexp: 'gexp-inputs' returns a list of <gexp-input> records., guix-commits, 2021/03/01
- 13/20: store: Micro-optimize object cache lookup., guix-commits, 2021/03/01
- 14/20: gexp: Reduce allocations in 'gexp-attribute'.,
guix-commits <=
- 20/20: build-system: Use 'input-tuples->gexp' and 'outputs->gexp'., guix-commits, 2021/03/01
- 19/20: build-system: Use 'sexp->gexp' for plain sexps., guix-commits, 2021/03/01