packages: Reduce code bloat due to list allocation in input fields.
* guix/packages.scm (add-input-labels): New procedure. (sanitize-inputs): Add case for (list …). Change-Id: Ice8241508ded51efd38867b97ca19c262b8c4363
This commit is contained in:
		
							parent
							
								
									76127069e0
								
							
						
					
					
						commit
						402d0a9b9d
					
				
					 1 changed files with 12 additions and 2 deletions
				
			
		| 
						 | 
					@ -438,16 +438,26 @@ from forcing GEXP-PROMISE."
 | 
				
			||||||
         inputs)
 | 
					         inputs)
 | 
				
			||||||
        (else (map add-input-label inputs))))
 | 
					        (else (map add-input-label inputs))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(define (add-input-labels . inputs)
 | 
				
			||||||
 | 
					  "Add labels to all of INPUTS."
 | 
				
			||||||
 | 
					  (map add-input-label inputs))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(define-syntax sanitize-inputs
 | 
					(define-syntax sanitize-inputs
 | 
				
			||||||
  ;; This is written as a macro rather than as a 'define-inlinable' procedure
 | 
					  ;; This is written as a macro rather than as a 'define-inlinable' procedure
 | 
				
			||||||
  ;; because as of Guile 3.0.9, peval can handle (null? '()) but not
 | 
					  ;; because as of Guile 3.0.9, peval can handle (null? '()) but not
 | 
				
			||||||
  ;; (null? (list x y z)); that residual 'null?' test contributes to code
 | 
					  ;; (null? (list x y z)); that residual 'null?' test contributes to code
 | 
				
			||||||
  ;; bloat.
 | 
					  ;; bloat.
 | 
				
			||||||
  (syntax-rules (quote)
 | 
					  (syntax-rules (quote list)
 | 
				
			||||||
    "Sanitize INPUTS by turning it into a list of name/package tuples if it's
 | 
					    "Sanitize INPUTS by turning it into a list of name/package tuples if it's
 | 
				
			||||||
not already the case."
 | 
					not already the case."
 | 
				
			||||||
    ((_ '()) '())
 | 
					    ((_ '()) '())
 | 
				
			||||||
    ((_ inputs) (maybe-add-input-labels inputs))))
 | 
					    ((_ (list args ...))
 | 
				
			||||||
 | 
					     ;; As of 3.0.9, (list ...) is open-coded, which can lead to a long list
 | 
				
			||||||
 | 
					     ;; of instructions.  To reduce code bloat in package modules where input
 | 
				
			||||||
 | 
					     ;; fields may create such lists, move list allocation to the callee.
 | 
				
			||||||
 | 
					     (add-input-labels args ...))
 | 
				
			||||||
 | 
					    ((_ inputs)
 | 
				
			||||||
 | 
					     (maybe-add-input-labels inputs))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(define-syntax current-location-vector
 | 
					(define-syntax current-location-vector
 | 
				
			||||||
  (lambda (s)
 | 
					  (lambda (s)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in a new issue