lib/io/splice.rb in io_splice-4.1.1 vs lib/io/splice.rb in io_splice-4.2.0

- old
+ new

@@ -45,29 +45,27 @@ need_open?(dst) and close << (dst = File.open(dst, "w")) rv = len 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, MAX_AT_ONCE, src_offset) + rv += n + src_offset += n if src_offset end else r, w = tmp = IO.pipe close.concat(tmp) + rv = 0 if len while len != 0 && n = partial(src, w, len, src_offset) src_offset += n if src_offset + rv += n len -= full(r, dst, n, nil) end else - rv = 0 - while n = partial(src, w, PIPE_CAPA, src_offset) + while n = partial(src, w, MAX_AT_ONCE, src_offset) src_offset += n if src_offset rv += full(r, dst, n, nil) end end end