utils: Memoize 'absolute-dirname'.

* guix/utils.scm (absolute-dirname): Wrap in 'mlambda'.
This commit is contained in:
Ludovic Courtès 2017-06-26 17:48:28 +02:00
parent 0b1be8fd57
commit 87b711d200
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 12 additions and 10 deletions

View File

@ -731,7 +731,9 @@ environment variable name like \"XDG_CONFIG_HOME\"; SUFFIX is a suffix like
;;; Source location.
;;;
(define (absolute-dirname file)
(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)
@ -741,7 +743,7 @@ failure."
;; needs to be canonicalized.
(if (string-prefix? "/" file)
(dirname file)
(canonicalize-path (dirname file))))))
(canonicalize-path (dirname file)))))))
(define-syntax current-source-directory
(lambda (s)