guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/04: download: 'tls-wrap' avoids intermediate buffer.


From: guix-commits
Subject: 01/04: download: 'tls-wrap' avoids intermediate buffer.
Date: Thu, 11 Mar 2021 17:24:57 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit 279d932b1ca7bfbb8657c41a84616dd0dfc6e0a8
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Wed Mar 10 22:51:47 2021 +0100

    download: 'tls-wrap' avoids intermediate buffer.
    
    * guix/build/download.scm (tls-wrap)[read!]: Read straight into BV
    instead of calling 'get-bytevector-some' and 'unget-bytevector'.
---
 guix/build/download.scm | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/guix/build/download.scm b/guix/build/download.scm
index 46af149..a027cd4 100644
--- a/guix/build/download.scm
+++ b/guix/build/download.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic 
Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 
Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;;
@@ -28,7 +28,6 @@
   #:use-module (guix build utils)
   #:use-module (guix progress)
   #:use-module (rnrs io ports)
-  #:use-module ((ice-9 binary-ports) #:select (unget-bytevector))
   #:use-module (rnrs bytevectors)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-11)
@@ -306,14 +305,10 @@ host name without trailing dot."
 
     (let ((record (session-record-port session)))
       (define (read! bv start count)
-        (define read-bv (get-bytevector-some record))
-        (if (eof-object? read-bv)
-            0  ; read! returns 0 on eof-object
-            (let ((read-bv-len (bytevector-length read-bv)))
-              (bytevector-copy! read-bv 0 bv start (min read-bv-len count))
-              (when (< count read-bv-len)
-                (unget-bytevector record bv count (- read-bv-len count)))
-              read-bv-len)))
+        (let ((read (get-bytevector-n! record bv start count)))
+          (if (eof-object? read)
+              0
+              read)))
       (define (write! bv start count)
         (put-bytevector record bv start count)
         (force-output record)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]