diff options
author | Ludovic Courtès <ludo@gnu.org> | 2014-10-13 23:07:47 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2014-10-13 23:34:09 +0200 |
commit | 998fb8fa1d6dfe64a0662aeaeb1ce7169b90dd57 (patch) | |
tree | 0fafb96367e836dc570815b38551f03b3db485d7 | |
parent | 8601d0ddcf5f0c1123d7679924560bc1b6b0e846 (diff) | |
download | patches-998fb8fa1d6dfe64a0662aeaeb1ce7169b90dd57.tar patches-998fb8fa1d6dfe64a0662aeaeb1ce7169b90dd57.tar.gz |
utils: Micro-optimize 'bytevector->base16-string'.
This reduces run time of (package-derivation s emacs) by ~1.5%.
* guix/utils.scm (bytevector->base16-string): Traverse BV from the end
so as to use 'string-concatenate' instead of
'string-concatenate-reverse'.
-rw-r--r-- | guix/utils.scm | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/guix/utils.scm b/guix/utils.scm index 2814247a68..6392914845 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -121,12 +121,13 @@ evaluate to a simple datum." 0)))) v)))))) (define chars base16-chars) - (let loop ((i 0) + (let loop ((i len) (r '())) - (if (= i len) - (string-concatenate-reverse r) - (loop (+ 1 i) - (cons (vector-ref chars (bytevector-u8-ref bv i)) r)))))) + (if (zero? i) + (string-concatenate r) + (let ((i (- i 1))) + (loop i + (cons (vector-ref chars (bytevector-u8-ref bv i)) r))))))) (define base16-string->bytevector (let ((chars->value (fold (lambda (i r) |