publish: Remove 'regexp-exec' call from the hot path.
* guix/scripts/publish.scm (extract-narinfo-hash): Rewrite without resorting to regexps.
This commit is contained in:
parent
0a94dc6396
commit
33463986ba
|
@ -565,13 +565,13 @@ has the given HASH of type ALGO."
|
||||||
" speaking. Welcome!")))
|
" speaking. Welcome!")))
|
||||||
port)))))
|
port)))))
|
||||||
|
|
||||||
(define extract-narinfo-hash
|
(define (extract-narinfo-hash str)
|
||||||
(let ((regexp (make-regexp "^([a-df-np-sv-z0-9]{32}).narinfo$")))
|
"Return the hash within the narinfo resource string STR, or false if STR
|
||||||
(lambda (str)
|
|
||||||
"Return the hash within the narinfo resource string STR, or false if STR
|
|
||||||
is invalid."
|
is invalid."
|
||||||
(and=> (regexp-exec regexp str)
|
(and (string-suffix? ".narinfo" str)
|
||||||
(cut match:substring <> 1)))))
|
(let ((base (string-drop-right str 8)))
|
||||||
|
(and (string-every %nix-base32-charset base)
|
||||||
|
base))))
|
||||||
|
|
||||||
(define (get-request? request)
|
(define (get-request? request)
|
||||||
"Return #t if REQUEST uses the GET method."
|
"Return #t if REQUEST uses the GET method."
|
||||||
|
|
Loading…
Reference in New Issue