io: get variables out of stream-copy loop

db4
Joe Groff 2011-10-13 20:25:53 -07:00
parent 09f55f82fa
commit 1c85631611
2 changed files with 9 additions and 3 deletions

View File

@ -1,4 +1,5 @@
USING: accessors io kernel math parser tools.test words ; USING: accessors io io.streams.string kernel math parser sbufs
sequences tools.test words ;
IN: io.tests IN: io.tests
{ f } [ { f } [
@ -62,3 +63,6 @@ M: dumb-writer stream-write1 vector>> push ; inline
[ stream-nl ] [ stream-nl ]
[ vector>> ] tri [ vector>> ] tri
] unit-test ] unit-test
{ SBUF" asdf" }
[ "asdf" <string-reader> 4 <sbuf> [ stream-copy ] keep ] unit-test

View File

@ -149,9 +149,11 @@ PRIVATE>
: contents* ( -- seq ) : contents* ( -- seq )
input-stream get stream-contents* ; inline input-stream get stream-contents* ; inline
: stream-copy* ( in out -- )
[ stream-write ] curry each-stream-block ; inline
: stream-copy ( in out -- ) : stream-copy ( in out -- )
[ [ [ write ] each-block ] with-output-stream ] [ [ stream-copy* ] with-disposal ] curry with-disposal ;
curry with-input-stream ;
! Default implementations of stream operations in terms of read1/write1 ! Default implementations of stream operations in terms of read1/write1