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
|
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
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue