From 1c856316119aca16a887ebd2c34ef4517af6dbd3 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 13 Oct 2011 20:25:53 -0700 Subject: [PATCH] io: get variables out of stream-copy loop --- core/io/io-tests.factor | 6 +++++- core/io/io.factor | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/core/io/io-tests.factor b/core/io/io-tests.factor index c604faf963..970eef0e34 100644 --- a/core/io/io-tests.factor +++ b/core/io/io-tests.factor @@ -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" 4 [ stream-copy ] keep ] unit-test diff --git a/core/io/io.factor b/core/io/io.factor index 59d019954d..d5151ba6da 100644 --- a/core/io/io.factor +++ b/core/io/io.factor @@ -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