io.streams.byte-array: faster with-byte-writer.

db4
John Benediktsson 2014-02-25 08:23:32 -08:00
parent f243b31ddd
commit 1170df3e71
1 changed files with 2 additions and 2 deletions

View File

@ -9,10 +9,10 @@ INSTANCE: byte-vector output-stream
M: byte-vector stream-element-type drop +byte+ ; inline
: <byte-writer> ( encoding -- stream )
512 <byte-vector> swap <encoder> ;
512 <byte-vector> swap <encoder> ; inline
: with-byte-writer ( encoding quot -- byte-array )
[ <byte-writer> ] dip [ output-stream get ] compose with-output-stream*
[ <byte-writer> ] dip [ with-output-stream* ] 2keep drop
dup encoder? [ stream>> ] when >byte-array ; inline
TUPLE: byte-reader { underlying byte-array read-only } { i array-capacity } ;