mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
emacs: Speed up starting the REPL.
Delay initializing variables. * emacs/guix-main.scm: (%packages): Rename to... (%package-vhash): ... this. Delay setting the value. (package-vhash): New procedure (wrapper for '%package-vhash'). (%package-table): Delay setting the value. (package-table): New procedure (wrapper for '%package-table'). (package-by-address, packages-by-name+version): Use wrappers.
This commit is contained in:
parent
619ff9066d
commit
183f42f90f
1 changed files with 28 additions and 18 deletions
|
@ -103,13 +103,19 @@ (define* (make-package-specification name #:optional version output)
|
|||
(define name+version->key cons)
|
||||
(define key->name+version car+cdr)
|
||||
|
||||
(define %packages
|
||||
(define %package-vhash
|
||||
(delay
|
||||
(fold-packages (lambda (pkg res)
|
||||
(vhash-consq (object-address pkg) pkg res))
|
||||
vlist-null))
|
||||
vlist-null)))
|
||||
|
||||
(define (package-vhash)
|
||||
"Return vhash of 'package ID (address)'/'package' pairs."
|
||||
(force %package-vhash))
|
||||
|
||||
(define %package-table
|
||||
(let ((table (make-hash-table (vlist-length %packages))))
|
||||
(delay
|
||||
(let ((table (make-hash-table (vlist-length (package-vhash)))))
|
||||
(vlist-for-each
|
||||
(lambda (elem)
|
||||
(match elem
|
||||
|
@ -119,8 +125,12 @@ (define %package-table
|
|||
(ref (hash-ref table key)))
|
||||
(hash-set! table key
|
||||
(if ref (cons pkg ref) (list pkg)))))))
|
||||
%packages)
|
||||
table))
|
||||
(package-vhash))
|
||||
table)))
|
||||
|
||||
(define (package-table)
|
||||
"Return hash table of 'name+version key'/'list of packages' pairs."
|
||||
(force %package-table))
|
||||
|
||||
(define (manifest-entry->name+version+output entry)
|
||||
(values
|
||||
|
@ -330,12 +340,12 @@ (define (package-param package param)
|
|||
;;; Finding packages.
|
||||
|
||||
(define (package-by-address address)
|
||||
(match (vhash-assq address %packages)
|
||||
(match (vhash-assq address (package-vhash))
|
||||
((_ . package) package)
|
||||
(_ #f)))
|
||||
|
||||
(define (packages-by-name+version name version)
|
||||
(or (hash-ref %package-table
|
||||
(or (hash-ref (package-table)
|
||||
(name+version->key name version))
|
||||
'()))
|
||||
|
||||
|
|
Loading…
Reference in a new issue