summaryrefslogtreecommitdiff
path: root/guix/store.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludovic.courtes@inria.fr>2017-07-21 14:50:16 +0200
committerLudovic Courtès <ludo@gnu.org>2017-07-21 17:03:25 +0200
commit35eb77b09d957019b2437e7681bd88013d67d3cd (patch)
tree0a4003c497926aaf49211f5bf50277a0551c537f /guix/store.scm
parent33463986ba5093c7513c9dc7702a66929f504aa5 (diff)
store: Rewrite 'store-path-hash-part' to not use regexps.
* guix/store.scm (store-path-hash-part): Rewrite without using a regexp. This speeds up 'guix substitute'.
Diffstat (limited to 'guix/store.scm')
-rw-r--r--guix/store.scm9
1 files changed, 6 insertions, 3 deletions
diff --git a/guix/store.scm b/guix/store.scm
index b15da54852..2563d26fa0 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -1549,9 +1549,12 @@ valid inputs."
(define (store-path-hash-part path)
"Return the hash part of PATH as a base32 string, or #f if PATH is not a
syntactically valid store path."
- (let ((path-rx (store-regexp* (%store-prefix))))
- (and=> (regexp-exec path-rx path)
- (cut match:substring <> 1))))
+ (and (string-prefix? (%store-prefix) path)
+ (let ((base (string-drop path (+ 1 (string-length (%store-prefix))))))
+ (and (> (string-length base) 33)
+ (let ((hash (string-take base 32)))
+ (and (string-every %nix-base32-charset hash)
+ hash))))))
(define (log-file store file)
"Return the build log file for FILE, or #f if none could be found. FILE