gnu-maintenance: Optimize `gnu-package?'.

* guix/gnu-maintenance.scm (gnu-package?): Capture a memoizing version
  of `gnu-package?'.
This commit is contained in:
Ludovic Courtès 2013-04-24 23:49:05 +02:00
parent d55a99fed3
commit 65b96a0c10
1 changed files with 10 additions and 9 deletions

View File

@ -210,6 +210,7 @@
(define gnu-package? (define gnu-package?
(memoize (memoize
(let ((official-gnu-packages (memoize official-gnu-packages)))
(lambda (package) (lambda (package)
"Return true if PACKAGE is a GNU package. This procedure may access the "Return true if PACKAGE is a GNU package. This procedure may access the
network to check in GNU's database." network to check in GNU's database."
@ -219,7 +220,7 @@ network to check in GNU's database."
(name (package-name package))) (name (package-name package)))
(or (and (string? url) (string-prefix? "mirror://gnu" url)) (or (and (string? url) (string-prefix? "mirror://gnu" url))
(and (member name (map gnu-package-name (official-gnu-packages))) (and (member name (map gnu-package-name (official-gnu-packages)))
#t)))))) #t)))))))
;;; ;;;