From 94a4f6d703d2bff417d40fdc787864fb5b6c544b Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 14 Jan 2019 18:16:27 -0700 Subject: [PATCH] io: streamline bytes output port --- racket/src/io/port/bytes-port.rkt | 4 +++- racket/src/io/port/write.rkt | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/racket/src/io/port/bytes-port.rkt b/racket/src/io/port/bytes-port.rkt index c750676d08..5656908c3f 100644 --- a/racket/src/io/port/bytes-port.rkt +++ b/racket/src/io/port/bytes-port.rkt @@ -180,7 +180,9 @@ (pipe-discard-all o)))) #:self o #:evt o - #:write-out o + #:write-out + (lambda (o src-bstr src-start src-end nonblock? enable-break? copy?) + ((core-output-port-write-out o) (core-port-self o) src-bstr src-start src-end nonblock? enable-break? copy?)) #:close (lambda (o) ((core-port-close o) (core-port-self o))) #:get-write-evt diff --git a/racket/src/io/port/write.rkt b/racket/src/io/port/write.rkt index fdadbb26bc..52e79c0254 100644 --- a/racket/src/io/port/write.rkt +++ b/racket/src/io/port/write.rkt @@ -33,6 +33,10 @@ (if zero-ok? 0 (try-again out extra-count-outs))] + [(exact-positive-integer? v) + (port-count-all! out extra-count-outs v bstr start) + (end-atomic) + v] [(evt? v) (end-atomic) (cond @@ -43,10 +47,6 @@ (sync v))) (start-atomic) (result-loop new-v)])] - [(exact-positive-integer? v) - (port-count-all! out extra-count-outs v bstr start) - (end-atomic) - v] [else (end-atomic) (internal-error (format "write-some-bytes: weird result ~s for ~s ~s ~s at ~s" v bstr start end out))]))]