summaryrefslogtreecommitdiff
path: root/guix/base64.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-01-09 01:01:04 +0100
committerLudovic Courtès <ludo@gnu.org>2015-01-09 01:01:04 +0100
commitb2ad9d9b084e52c1657f0df7b22690abb1f86acd (patch)
treee0c63c86a7acfbb31dbeca9c78c118f032875707 /guix/base64.scm
parent05f0607bfc3d47ee493e12051272656db58fcd04 (diff)
downloadgnu-guix-b2ad9d9b084e52c1657f0df7b22690abb1f86acd.tar
gnu-guix-b2ad9d9b084e52c1657f0df7b22690abb1f86acd.tar.gz
base64: Inline arithmetic operations.
* guix/base64.scm (define-alias): New macro. (fxbit-field, fxarithmetic-shift, fxarithmetic-shift-left, fxand, fxior, fxxor): New aliases.
Diffstat (limited to 'guix/base64.scm')
-rw-r--r--guix/base64.scm22
1 files changed, 20 insertions, 2 deletions
diff --git a/guix/base64.scm b/guix/base64.scm
index f7f7f5f4e1..e4d2ec589b 100644
--- a/guix/base64.scm
+++ b/guix/base64.scm
@@ -4,6 +4,8 @@
;; (guix base64) by Nikita Karetnikov <nikita@karetnikov.org> on
;; February 12, 2014.
;;
+;; Some optimizations made by Ludovic Courtès <ludo@gnu.org>, 2015.
+;;
;; Copyright © 2009, 2010 Göran Weinholt <goran@weinholt.se>
;;
;; This program is free software: you can redistribute it and/or modify
@@ -33,7 +35,23 @@
(only (srfi :13 strings)
string-index
string-prefix? string-suffix?
- string-concatenate string-trim-both))
+ string-concatenate string-trim-both)
+ (only (guile) ash logior))
+
+
+ (define-syntax define-alias
+ (syntax-rules ()
+ ((_ new old)
+ (define-syntax new (identifier-syntax old)))))
+
+ ;; Force the use of Guile's own primitives to avoid the overhead of its 'fx'
+ ;; procedures.
+ (define-alias fxbit-field bitwise-bit-field)
+ (define-alias fxarithmetic-shift ash)
+ (define-alias fxarithmetic-shift-left ash)
+ (define-alias fxand logand)
+ (define-alias fxior logior)
+ (define-alias fxxor logxor)
(define base64-alphabet
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
@@ -209,4 +227,4 @@
line-length #f base64-alphabet port)
(display (string-append "\n-----END " type "-----\n") port))
((port type bv)
- (put-delimited-base64 port type bv 76))))) \ No newline at end of file
+ (put-delimited-base64 port type bv 76)))))