mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
utils: Memoize 'absolute-dirname'.
* guix/utils.scm (absolute-dirname): Wrap in 'mlambda'.
This commit is contained in:
parent
0b1be8fd57
commit
87b711d200
1 changed files with 12 additions and 10 deletions
|
@ -731,17 +731,19 @@ (define (read! bv start n)
|
|||
;;; Source location.
|
||||
;;;
|
||||
|
||||
(define (absolute-dirname file)
|
||||
"Return the absolute name of the directory containing FILE, or #f upon
|
||||
(define absolute-dirname
|
||||
;; Memoize to avoid repeated 'stat' storms from 'search-path'.
|
||||
(mlambda (file)
|
||||
"Return the absolute name of the directory containing FILE, or #f upon
|
||||
failure."
|
||||
(match (search-path %load-path file)
|
||||
(#f #f)
|
||||
((? string? file)
|
||||
;; If there are relative names in %LOAD-PATH, FILE can be relative and
|
||||
;; needs to be canonicalized.
|
||||
(if (string-prefix? "/" file)
|
||||
(dirname file)
|
||||
(canonicalize-path (dirname file))))))
|
||||
(match (search-path %load-path file)
|
||||
(#f #f)
|
||||
((? string? file)
|
||||
;; If there are relative names in %LOAD-PATH, FILE can be relative and
|
||||
;; needs to be canonicalized.
|
||||
(if (string-prefix? "/" file)
|
||||
(dirname file)
|
||||
(canonicalize-path (dirname file)))))))
|
||||
|
||||
(define-syntax current-source-directory
|
||||
(lambda (s)
|
||||
|
|
Loading…
Reference in a new issue