utils: Memoize 'absolute-dirname'.
* guix/utils.scm (absolute-dirname): Wrap in 'mlambda'.
This commit is contained in:
parent
0b1be8fd57
commit
87b711d200
|
@ -731,17 +731,19 @@ environment variable name like \"XDG_CONFIG_HOME\"; SUFFIX is a suffix like
|
||||||
;;; Source location.
|
;;; Source location.
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
(define (absolute-dirname file)
|
(define absolute-dirname
|
||||||
"Return the absolute name of the directory containing FILE, or #f upon
|
;; Memoize to avoid repeated 'stat' storms from 'search-path'.
|
||||||
|
(mlambda (file)
|
||||||
|
"Return the absolute name of the directory containing FILE, or #f upon
|
||||||
failure."
|
failure."
|
||||||
(match (search-path %load-path file)
|
(match (search-path %load-path file)
|
||||||
(#f #f)
|
(#f #f)
|
||||||
((? string? file)
|
((? string? file)
|
||||||
;; If there are relative names in %LOAD-PATH, FILE can be relative and
|
;; If there are relative names in %LOAD-PATH, FILE can be relative and
|
||||||
;; needs to be canonicalized.
|
;; needs to be canonicalized.
|
||||||
(if (string-prefix? "/" file)
|
(if (string-prefix? "/" file)
|
||||||
(dirname file)
|
(dirname file)
|
||||||
(canonicalize-path (dirname file))))))
|
(canonicalize-path (dirname file)))))))
|
||||||
|
|
||||||
(define-syntax current-source-directory
|
(define-syntax current-source-directory
|
||||||
(lambda (s)
|
(lambda (s)
|
||||||
|
|
Loading…
Reference in New Issue