diff options
author | David Thompson <dthompson2@worcester.edu> | 2024-11-09 14:04:47 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2024-11-09 14:04:47 -0500 |
commit | 045e3496be5cc0598da18f82968051b0d39680f3 (patch) | |
tree | 116d042ffa28f14ff14ea746321f37dcdd52907a | |
parent | 0a2de333d1c7f190078e307fc490f6fe98e8b0bb (diff) |
base64: Simplify reading from bytevector in base64-encode.
-rw-r--r-- | chickadee/base64.scm | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/chickadee/base64.scm b/chickadee/base64.scm index 8fe384c..6575785 100644 --- a/chickadee/base64.scm +++ b/chickadee/base64.scm @@ -122,17 +122,14 @@ return a bytevector containing the decoded data." (let ((offset (* i 3))) (cond ((< i groups) - (let ((x (logior (ash (bytevector-u8-ref bv offset) 16) - (ash (bytevector-u8-ref bv (1+ offset)) 8) - (bytevector-u8-ref bv (+ offset 2))))) + (let ((x (bytevector-uint-ref bv offset (endianness big) 3))) (put-char port (encode (ash (logand x #xfc0000) -18))) (put-char port (encode (ash (logand x #x03f000) -12))) (put-char port (encode (ash (logand x #x000fc0) -6))) (put-char port (encode (logand x #x00003f))) (lp (1+ i)))) ((eq? padding 1) - (let ((x (logior (ash (bytevector-u8-ref bv offset) 8) - (bytevector-u8-ref bv (1+ offset))))) + (let ((x (bytevector-u16-ref bv offset (endianness big)))) (put-char port (encode (ash (logand x #xfc00) -10))) (put-char port (encode (ash (logand x #x03f0) -4))) (put-char port (encode (ash (logand x #x000f) 2))) |