diff options
-rw-r--r-- | guix/lzlib.scm | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/guix/lzlib.scm b/guix/lzlib.scm index d596f0d95d..a6dac46049 100644 --- a/guix/lzlib.scm +++ b/guix/lzlib.scm @@ -491,27 +491,19 @@ perhaps not yet read." ;; High level functions. -(define %lz-decompress-input-buffer-size (* 64 1024)) - (define* (lzread! decoder file-port bv #:optional (start 0) (count (bytevector-length bv))) "Read up to COUNT bytes from FILE-PORT into BV at offset START. Return the number of uncompressed bytes actually read; it is zero if COUNT is zero or if the end-of-stream has been reached." ;; WARNING: Because we don't alternate between lz-reads and lz-writes, we can't - ;; process more than %lz-decompress-input-buffer-size from the file-port. - (when (> count %lz-decompress-input-buffer-size) - (set! count %lz-decompress-input-buffer-size)) - (let* ((written 0) - (read 0) - (file-bv (get-bytevector-n file-port count))) + ;; process more than lz-decompress-write-size from the file-port. + (when (> count (lz-decompress-write-size decoder)) + (set! count (lz-decompress-write-size decoder))) + (let ((file-bv (get-bytevector-n file-port count))) (unless (eof-object? file-bv) - (begin - (while (and (< 0 (lz-decompress-write-size decoder)) - (< written (bytevector-length file-bv))) - (set! written (+ written - (lz-decompress-write decoder file-bv written - (- (bytevector-length file-bv) written))))))) + (lz-decompress-write decoder file-bv 0 (bytevector-length file-bv)))) + (let ((read 0)) (let loop ((rd 0)) (if (< start (bytevector-length bv)) (begin |