io: get variables out of stream-copy loop
parent
09f55f82fa
commit
1c85631611
|
@ -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
|
||||
|
||||
{ f } [
|
||||
|
@ -62,3 +63,6 @@ M: dumb-writer stream-write1 vector>> push ; inline
|
|||
[ stream-nl ]
|
||||
[ vector>> ] tri
|
||||
] unit-test
|
||||
|
||||
{ SBUF" asdf" }
|
||||
[ "asdf" <string-reader> 4 <sbuf> [ stream-copy ] keep ] unit-test
|
||||
|
|
|
@ -149,9 +149,11 @@ PRIVATE>
|
|||
: contents* ( -- seq )
|
||||
input-stream get stream-contents* ; inline
|
||||
|
||||
: stream-copy* ( in out -- )
|
||||
[ stream-write ] curry each-stream-block ; inline
|
||||
|
||||
: stream-copy ( in out -- )
|
||||
[ [ [ write ] each-block ] with-output-stream ]
|
||||
curry with-input-stream ;
|
||||
[ [ stream-copy* ] with-disposal ] curry with-disposal ;
|
||||
|
||||
! Default implementations of stream operations in terms of read1/write1
|
||||
|
||||
|
|
Loading…
Reference in New Issue