gexp: Reduce allocations in 'gexp-attribute'.
* guix/gexp.scm (gexp-attribute): Use 'fold' and 'fold/tree' instead of 'append-map'.master
parent
c8bd5fa59c
commit
fcde4e10b8
|
@ -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
|
||||||
|
|
||||||
|
|
Reference in New Issue