From: Chris Hanson Date: Fri, 28 Apr 2017 05:42:43 +0000 (-0700) Subject: Use index procedures to simplify read-bytevector!. X-Git-Tag: mit-scheme-pucked-9.2.12~14^2~121 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=fbaa36c3a7e249cbcf0adabace8ea70db7ff9b24;p=mit-scheme.git Use index procedures to simplify read-bytevector!. --- diff --git a/src/runtime/binary-port.scm b/src/runtime/binary-port.scm index dc8d16b4f..785e0c550 100644 --- a/src/runtime/binary-port.scm +++ b/src/runtime/binary-port.scm @@ -400,26 +400,13 @@ USA. (make-bytevector 0)))) (define (read-bytevector! bytevector #!optional port start end) - (let ((ib (check-input-port port 'read-bytevector!)) - (end - (if (default-object? end) - (bytevector-length bytevector) - (begin - (guarantee index-fixnum? end 'read-bytevector!) - (if (not (fix:<= end (bytevector-length bytevector))) - (error:bad-range-argument end 'read-bytevector)) - end)))) - (let ((start - (if (default-object? start) - 0 - (begin - (guarantee index-fixnum? start 'read-bytevector!) - (if (not (fix:<= start end)) - (error:bad-range-argument start 'read-bytevector!)) - start)))) - (if (fix:< start end) - (%read-bytevector! ib bytevector start end 'read-bytevector!) - 0)))) + (let* ((caller 'read-bytevector!) + (ib (check-input-port port caller)) + (end (fix:end-index end (bytevector-length bytevector) caller)) + (start (fix:start-index start end caller))) + (if (fix:< start end) + (%read-bytevector! ib bytevector start end caller) + 0))) (define (%read-bytevector! ib bytevector start end caller)