guix-commits
[Top][All Lists]
Advanced

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

02/03: guix: Remove duplicate definitions of dump-port.


From: guix-commits
Subject: 02/03: guix: Remove duplicate definitions of dump-port.
Date: Fri, 20 May 2022 16:13:41 -0400 (EDT)

rekado pushed a commit to branch master
in repository guix.

commit e35c08d2f910ddab027bc45188a0ba838958e5f6
Author: Ricardo Wurmus <rekado@elephly.net>
AuthorDate: Fri May 20 20:39:48 2022 +0200

    guix: Remove duplicate definitions of dump-port.
    
    * guix/store.scm (dump-port): Remove procedure; autoload from (guix build
    utils) instead.
    * guix/store/deduplication.scm (dump-port): Remove procedure; unhide 
dump-port
    from (guix build utils).
---
 guix/store.scm               | 24 +-----------------------
 guix/store/deduplication.scm | 27 +--------------------------
 2 files changed, 2 insertions(+), 49 deletions(-)

diff --git a/guix/store.scm b/guix/store.scm
index a3240eb2e0..82fca14cd9 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -33,6 +33,7 @@
   #:use-module (gcrypt hash)
   #:use-module (guix profiling)
   #:autoload   (guix build syscalls) (terminal-columns)
+  #:autoload   (guix build utils) (dump-port)
   #:use-module (rnrs bytevectors)
   #:use-module (ice-9 binary-ports)
   #:use-module ((ice-9 control) #:select (let/ec))
@@ -682,29 +683,6 @@ automatically close the store when the dynamic extent of 
EXP is left."
   ;; The port where build output is sent.
   (make-parameter (current-error-port)))
 
-(define* (dump-port in out
-                    #:optional len
-                    #:key (buffer-size 16384))
-  "Read LEN bytes from IN (or as much as possible if LEN is #f) and write it
-to OUT, using chunks of BUFFER-SIZE bytes."
-  (define buffer
-    (make-bytevector buffer-size))
-
-  (let loop ((total 0)
-             (bytes (get-bytevector-n! in buffer 0
-                                       (if len
-                                           (min len buffer-size)
-                                           buffer-size))))
-    (or (eof-object? bytes)
-        (and len (= total len))
-        (let ((total (+ total bytes)))
-          (put-bytevector out buffer 0 bytes)
-          (loop total
-                (get-bytevector-n! in buffer 0
-                                   (if len
-                                       (min (- len total) buffer-size)
-                                       buffer-size)))))))
-
 (define %newlines
   ;; Newline characters triggering a flush of 'current-build-output-port'.
   ;; Unlike Guile's 'line, we flush upon #\return so that progress reports
diff --git a/guix/store/deduplication.scm b/guix/store/deduplication.scm
index 370df4a74c..ab982e3b3d 100644
--- a/guix/store/deduplication.scm
+++ b/guix/store/deduplication.scm
@@ -22,7 +22,7 @@
 
 (define-module (guix store deduplication)
   #:use-module (gcrypt hash)
-  #:use-module ((guix build utils) #:hide (dump-port))
+  #:use-module (guix build utils)
   #:use-module (guix build syscalls)
   #:use-module (guix base32)
   #:use-module (srfi srfi-11)
@@ -38,31 +38,6 @@
             dump-file/deduplicate
             copy-file/deduplicate))
 
-;; TODO: Remove once 'dump-port' in (guix build utils) has an optional 'len'
-;; parameter.
-(define* (dump-port in out
-                    #:optional len
-                    #:key (buffer-size 16384))
-  "Read LEN bytes from IN (or as much as possible if LEN is #f) and write it
-to OUT, using chunks of BUFFER-SIZE bytes."
-  (define buffer
-    (make-bytevector buffer-size))
-
-  (let loop ((total 0)
-             (bytes (get-bytevector-n! in buffer 0
-                                       (if len
-                                           (min len buffer-size)
-                                           buffer-size))))
-    (or (eof-object? bytes)
-        (and len (= total len))
-        (let ((total (+ total bytes)))
-          (put-bytevector out buffer 0 bytes)
-          (loop total
-                (get-bytevector-n! in buffer 0
-                                   (if len
-                                       (min (- len total) buffer-size)
-                                       buffer-size)))))))
-
 (define (nar-sha256 file)
   "Gives the sha256 hash of a file and the size of the file in nar form."
   (let-values (((port get-hash) (open-sha256-port)))



reply via email to

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