about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-05-18 13:47:54 -0700
committerEric Wong <normalperson@yhbt.net>2011-05-18 13:48:34 -0700
commitaad5139884ad055d8aafb4316360e9f486b2d452 (patch)
treed6c159bee22499f88c51413dc25d342ce7687e5d
parent45436d6251b3310e3ac02f1590e473a2602762ac (diff)
downloadruby_io_splice-aad5139884ad055d8aafb4316360e9f486b2d452.tar.gz
No need to loop on IO::Splice.full, it already loops
internally whenever it makes sense.
-rw-r--r--lib/io/splice.rb13
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/io/splice.rb b/lib/io/splice.rb
index 4b666f8..84bca5e 100644
--- a/lib/io/splice.rb
+++ b/lib/io/splice.rb
@@ -47,14 +47,11 @@ module IO::Splice
     src, dst = src.to_io, dst.to_io
 
     if src.stat.pipe? || dst.stat.pipe?
-      if len
-        len -= full(src, dst, len, src_offset) until len == 0
-      else
-        rv = 0
-        while n = partial(src, dst, PIPE_CAPA, src_offset)
-          rv += n
-          src_offset += n if src_offset
-        end
+      return full(src, dst, len, src_offset) if len
+      rv = 0
+      while n = partial(src, dst, PIPE_CAPA, src_offset)
+        rv += n
+        src_offset += n if src_offset
       end
     else
       r, w = tmp = IO.pipe