me
/
guix
Archived
1
0
Fork 0

gexp: Reduce allocations in 'gexp-attribute'.

* guix/gexp.scm (gexp-attribute): Use 'fold' and 'fold/tree' instead of
'append-map'.
master
Ludovic Courtès 2021-02-23 14:19:48 +01:00
parent c8bd5fa59c
commit fcde4e10b8
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 22 additions and 13 deletions

View File

@ -757,19 +757,28 @@ attribute that is traversed."
(append (let ((attribute (self-attribute gexp))) (append (let ((attribute (self-attribute gexp)))
(validate gexp attribute) (validate gexp attribute)
attribute) attribute)
(append-map (match-lambda (reverse
(fold (lambda (input result)
(match input
(($ <gexp-input> (? gexp? exp)) (($ <gexp-input> (? gexp? exp))
(gexp-attribute exp self-attribute (append (gexp-attribute exp self-attribute
#:validate validate)) #:validate validate)
result))
(($ <gexp-input> (lst ...)) (($ <gexp-input> (lst ...))
(append-map (lambda (item) (fold/tree (lambda (obj result)
(gexp-attribute item self-attribute (match obj
#:validate ((? gexp? exp)
validate)) (append (gexp-attribute exp self-attribute
#:validate validate)
result))
(_
result)))
result
lst)) lst))
(_ (_
'())) result)))
(gexp-references gexp))) '()
(gexp-references gexp))))
equal?) equal?)
'())) ;plain Scheme data type '())) ;plain Scheme data type