guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] 02/08: Minor tweak to Scheme peek-byte.


From: Andy Wingo
Subject: [Guile-commits] 02/08: Minor tweak to Scheme peek-byte.
Date: Wed, 04 May 2016 10:43:53 +0000

wingo pushed a commit to branch wip-port-refactor
in repository guile.

commit 422f65fe09e93bff383cc3e818204902ed0d32d2
Author: Andy Wingo <address@hidden>
Date:   Sun May 1 22:00:37 2016 +0200

    Minor tweak to Scheme peek-byte.
    
    * module/ice-9/ports.scm (peek-byte): Use second return from
      fill-input.
---
 module/ice-9/ports.scm |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/module/ice-9/ports.scm b/module/ice-9/ports.scm
index 2bc12c5..db1c6f7 100644
--- a/module/ice-9/ports.scm
+++ b/module/ice-9/ports.scm
@@ -241,11 +241,12 @@
          (cur (port-buffer-cur buf)))
     (if (< cur (port-buffer-end buf))
         (bytevector-u8-ref (port-buffer-bytevector buf) cur)
-        (let* ((buf (fill-input port))
-               (cur (port-buffer-cur buf)))
-          (if (< cur (port-buffer-end buf))
-              (bytevector-u8-ref (port-buffer-bytevector buf) cur)
-              the-eof-object)))))
+        (call-with-values (lambda () (fill-input port))
+          (lambda (buf buffered)
+            (if (zero? buffered)
+                the-eof-object
+                (bytevector-u8-ref (port-buffer-bytevector buf)
+                                   (port-buffer-cur buf))))))))
 
 
 



reply via email to

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