diff options
author | Ludovic Courtès <ludovic.courtes@inria.fr> | 2017-07-21 14:48:52 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2017-07-21 17:03:24 +0200 |
commit | 33463986ba5093c7513c9dc7702a66929f504aa5 (patch) | |
tree | a2eb52de54f88fc24b9ff4d31bbce9cdef21b894 | |
parent | 0a94dc63964c88903079c0a040162439fe07a306 (diff) | |
download | guix-33463986ba5093c7513c9dc7702a66929f504aa5.tar guix-33463986ba5093c7513c9dc7702a66929f504aa5.tar.gz |
publish: Remove 'regexp-exec' call from the hot path.
* guix/scripts/publish.scm (extract-narinfo-hash): Rewrite without
resorting to regexps.
-rw-r--r-- | guix/scripts/publish.scm | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm index a7e3e6d629..cb1abc32fb 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." |