[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
15/15: gexp: Reduce allocations in 'gexp-attribute'.
From: |
guix-commits |
Subject: |
15/15: gexp: Reduce allocations in 'gexp-attribute'. |
Date: |
Tue, 23 Feb 2021 08:34:04 -0500 (EST) |
civodul pushed a commit to branch wip-build-systems-gexp
in repository guix.
commit 0ffad81025dd34a613befd6c5a328c1394aaa0a8
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
- 11/15: store: Object cache profiling shows the number of entries., (continued)
- 11/15: store: Object cache profiling shows the number of entries., guix-commits, 2021/02/23
- 10/15: gexp: Micro-optimize 'gexp->sexp' and 'lower-inputs'., guix-commits, 2021/02/23
- 08/15: gexp: 'gexp-inputs' returns both native and non-native inputs., guix-commits, 2021/02/23
- 14/15: store: Micro-optimize object cache lookup., guix-commits, 2021/02/23
- 04/15: packages: Core procedures are written in monadic style., guix-commits, 2021/02/23
- 02/15: packages: Turn 'bag->derivation' into a monadic procedure., guix-commits, 2021/02/23
- 13/15: grafts: Inline 'grafting?' and 'set-grafting'., guix-commits, 2021/02/23
- 07/15: gexp: 'gexp-inputs' returns a list of <gexp-input> records., guix-commits, 2021/02/23
- 12/15: gexp: Reduce allocations while traversing lists., guix-commits, 2021/02/23
- 01/15: build-system: Rewrite using gexps., guix-commits, 2021/02/23
- 15/15: gexp: Reduce allocations in 'gexp-attribute'.,
guix-commits <=