diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-20 04:59:04 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-20 04:59:04 +0000 |
commit | 01c433b58ccdbde5b488901e2accda87d931abd9 (patch) | |
tree | 5d093538b21a26e91ce4d3100f0ba5841ccc715a /io.c | |
parent | f0fbfeda519f7e0365996255c80f78c4b14d6037 (diff) |
* io.c (copy_stream_fallback): write directly (bypassing write method)
if possible.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -6579,7 +6579,7 @@ copy_stream_fallback_body(VALUE arg) while (1) { long numwrote; - long l = buflen < rest ? buflen : rest; + long l; if (stp->copy_length == (off_t)-1) { l = buflen; } @@ -6604,9 +6604,18 @@ copy_stream_fallback_body(VALUE arg) if (off != (off_t)-1) off += ss; } - n = rb_io_write(stp->dst, buf); - numwrote = NUM2LONG(n); - stp->total += numwrote; + if (stp->dst_fd == -1) { + n = rb_io_write(stp->dst, buf); + numwrote = NUM2LONG(n); + stp->total += numwrote; + } + else { + ssize_t ss; + numwrote = RSTRING_LEN(buf); + ss = copy_stream_write(stp, RSTRING_PTR(buf), numwrote); + if (ss == -1) + return Qnil; + } rest -= numwrote; } |