[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
09/10: gexp: Reduce allocations in 'gexp-attribute'.
From: |
guix-commits |
Subject: |
09/10: gexp: Reduce allocations in 'gexp-attribute'. |
Date: |
Tue, 23 Feb 2021 09:27:25 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit fcde4e10b87db9a71dbc115af548aeabe9068310
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 cad57f6..8cd44ba 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -757,19 +757,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
- branch master updated (3c548c3 -> 0a912b3), guix-commits, 2021/02/23
- 03/10: gexp: Micro-optimize sexp serialization., guix-commits, 2021/02/23
- 01/10: grafts: Inline 'grafting?' and 'set-grafting'., guix-commits, 2021/02/23
- 04/10: gexp: 'gexp-inputs' returns a list of <gexp-input> records., guix-commits, 2021/02/23
- 05/10: gexp: 'gexp-inputs' returns both native and non-native inputs., guix-commits, 2021/02/23
- 08/10: gexp: Reduce allocations while traversing lists., guix-commits, 2021/02/23
- 07/10: gexp: Micro-optimize 'gexp->sexp' and 'lower-inputs'., guix-commits, 2021/02/23
- 06/10: gexp: Keep 'lower-inputs' private., guix-commits, 2021/02/23
- 09/10: gexp: Reduce allocations in 'gexp-attribute'.,
guix-commits <=
- 10/10: store: Micro-optimize object cache lookup., guix-commits, 2021/02/23
- 02/10: store: Object cache profiling shows the number of entries., guix-commits, 2021/02/23