aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-04-24 23:49:05 +0200
committerLudovic Courtès <ludo@gnu.org>2013-04-25 00:13:56 +0200
commit65b96a0c10abf88dbdf1668e15d5af0120dc92f7 (patch)
tree0b499b77b6cdc7b13a5753d8bce717811a8751a4
parentd55a99fed30b2ee47725f07bf26208fb4b13a110 (diff)
downloadpatches-65b96a0c10abf88dbdf1668e15d5af0120dc92f7.tar
patches-65b96a0c10abf88dbdf1668e15d5af0120dc92f7.tar.gz
gnu-maintenance: Optimize `gnu-package?'.
* guix/gnu-maintenance.scm (gnu-package?): Capture a memoizing version of `gnu-package?'.
-rw-r--r--guix/gnu-maintenance.scm19
1 files changed, 10 insertions, 9 deletions
diff --git a/guix/gnu-maintenance.scm b/guix/gnu-maintenance.scm
index 30c45ec0c6..36aad7a987 100644
--- a/guix/gnu-maintenance.scm
+++ b/guix/gnu-maintenance.scm
@@ -210,16 +210,17 @@
(define gnu-package?
(memoize
- (lambda (package)
- "Return true if PACKAGE is a GNU package. This procedure may access the
+ (let ((official-gnu-packages (memoize official-gnu-packages)))
+ (lambda (package)
+ "Return true if PACKAGE is a GNU package. This procedure may access the
network to check in GNU's database."
- ;; TODO: Find a way to determine that a package is non-GNU without going
- ;; through the network.
- (let ((url (and=> (package-source package) origin-uri))
- (name (package-name package)))
- (or (and (string? url) (string-prefix? "mirror://gnu" url))
- (and (member name (map gnu-package-name (official-gnu-packages)))
- #t))))))
+ ;; TODO: Find a way to determine that a package is non-GNU without going
+ ;; through the network.
+ (let ((url (and=> (package-source package) origin-uri))
+ (name (package-name package)))
+ (or (and (string? url) (string-prefix? "mirror://gnu" url))
+ (and (member name (map gnu-package-name (official-gnu-packages)))
+ #t)))))))
;;;