[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/07: store: Rewrite 'store-path-hash-part' to not use regexps.
From: |
Ludovic Courtès |
Subject: |
05/07: store: Rewrite 'store-path-hash-part' to not use regexps. |
Date: |
Fri, 21 Jul 2017 11:04:13 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 35eb77b09d957019b2437e7681bd88013d67d3cd
Author: Ludovic Courtès <address@hidden>
Date: Fri Jul 21 14:50:16 2017 +0200
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'.
---
guix/store.scm | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/guix/store.scm b/guix/store.scm
index b15da54..2563d26 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
- branch master updated (0cf9f9b -> c95644f), Ludovic Courtès, 2017/07/21
- 03/07: base32: Export the base32 charsets., Ludovic Courtès, 2017/07/21
- 04/07: publish: Remove 'regexp-exec' call from the hot path., Ludovic Courtès, 2017/07/21
- 05/07: store: Rewrite 'store-path-hash-part' to not use regexps.,
Ludovic Courtès <=
- 06/07: publish: Avoid 'valid-path?' RPC for non-existent items., Ludovic Courtès, 2017/07/21
- 07/07: publish: Make the cache eviction policy less aggressive., Ludovic Courtès, 2017/07/21
- 01/07: substitute: Optimize hash-part-to-path conversion on non-200 responses., Ludovic Courtès, 2017/07/21
- 02/07: substitute: Avoid repeated calls to 'length'., Ludovic Courtès, 2017/07/21