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'.
This commit is contained in:
parent
33463986ba
commit
35eb77b09d
|
@ -1549,9 +1549,12 @@ valid inputs."
|
||||||
(define (store-path-hash-part path)
|
(define (store-path-hash-part path)
|
||||||
"Return the hash part of PATH as a base32 string, or #f if PATH is not a
|
"Return the hash part of PATH as a base32 string, or #f if PATH is not a
|
||||||
syntactically valid store path."
|
syntactically valid store path."
|
||||||
(let ((path-rx (store-regexp* (%store-prefix))))
|
(and (string-prefix? (%store-prefix) path)
|
||||||
(and=> (regexp-exec path-rx path)
|
(let ((base (string-drop path (+ 1 (string-length (%store-prefix))))))
|
||||||
(cut match:substring <> 1))))
|
(and (> (string-length base) 33)
|
||||||
|
(let ((hash (string-take base 32)))
|
||||||
|
(and (string-every %nix-base32-charset hash)
|
||||||
|
hash))))))
|
||||||
|
|
||||||
(define (log-file store file)
|
(define (log-file store file)
|
||||||
"Return the build log file for FILE, or #f if none could be found. FILE
|
"Return the build log file for FILE, or #f if none could be found. FILE
|
||||||
|
|
Loading…
Reference in New Issue