[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/07: publish: Remove 'regexp-exec' call from the hot path.
From: |
Ludovic Courtès |
Subject: |
04/07: publish: Remove 'regexp-exec' call from the hot path. |
Date: |
Fri, 21 Jul 2017 11:04:13 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 33463986ba5093c7513c9dc7702a66929f504aa5
Author: Ludovic Courtès <address@hidden>
Date: Fri Jul 21 14:48:52 2017 +0200
publish: Remove 'regexp-exec' call from the hot path.
* guix/scripts/publish.scm (extract-narinfo-hash): Rewrite without
resorting to regexps.
---
guix/scripts/publish.scm | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm
index a7e3e6d..cb1abc3 100644
--- a/guix/scripts/publish.scm
+++ b/guix/scripts/publish.scm
@@ -565,13 +565,13 @@ has the given HASH of type ALGO."
" speaking. Welcome!")))
port)))))
-(define extract-narinfo-hash
- (let ((regexp (make-regexp "^([a-df-np-sv-z0-9]{32}).narinfo$")))
- (lambda (str)
- "Return the hash within the narinfo resource string STR, or false if STR
+(define (extract-narinfo-hash str)
+ "Return the hash within the narinfo resource string STR, or false if STR
is invalid."
- (and=> (regexp-exec regexp str)
- (cut match:substring <> 1)))))
+ (and (string-suffix? ".narinfo" str)
+ (let ((base (string-drop-right str 8)))
+ (and (string-every %nix-base32-charset base)
+ base))))
(define (get-request? request)
"Return #t if REQUEST uses the GET method."
- 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 <=
- 05/07: store: Rewrite 'store-path-hash-part' to not use regexps., Ludovic Courtès, 2017/07/21
- 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