[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/06: utils: Memoize 'absolute-dirname'.
From: |
guix-commits |
Subject: |
04/06: utils: Memoize 'absolute-dirname'. |
Date: |
Wed, 19 Dec 2018 18:09:43 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit 87b711d200ad13eaef284bdd1ab77f85618b0498
Author: Ludovic Courtès <address@hidden>
Date: Mon Jun 26 17:48:28 2017 +0200
utils: Memoize 'absolute-dirname'.
* guix/utils.scm (absolute-dirname): Wrap in 'mlambda'.
---
guix/utils.scm | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/guix/utils.scm b/guix/utils.scm
index 9bad06d..ed1a418 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -731,17 +731,19 @@ environment variable name like \"XDG_CONFIG_HOME\";
SUFFIX is a suffix like
;;; 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)
- branch master updated (207a79b -> 9012d22), guix-commits, 2018/12/19
- 01/06: store: Add 'GUIX_PROFILING' support for the object cache., guix-commits, 2018/12/19
- 03/06: packages: Turn 'cache!' into a single-value-return cache., guix-commits, 2018/12/19
- 02/06: Use 'mapm' instead of 'sequence' + 'map'., guix-commits, 2018/12/19
- 04/06: utils: Memoize 'absolute-dirname'.,
guix-commits <=
- 05/06: download: 'built-in-builders*' relies on the functional cache., guix-commits, 2018/12/19
- 06/06: services: zabbix-front-end: Tweak error and hint messages., guix-commits, 2018/12/19