From f5ce9388de5f78e51266b1a8caa4817a8df5cffb Mon Sep 17 00:00:00 2001 From: Louis Schmieder Date: Mon, 26 Apr 2021 08:59:23 +0200 Subject: [PATCH] io: make io.cp use chunks (#9877) --- vlib/io/io.v | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/vlib/io/io.v b/vlib/io/io.v index 45cf7938a4..6648509974 100644 --- a/vlib/io/io.v +++ b/vlib/io/io.v @@ -1,15 +1,16 @@ module io const ( - buf_max_len = 5 * 1024 + buf_max_len = 1024 ) pub fn cp(dst Writer, src Reader) ? { - mut buf := read_all(reader: src) or { - return err - } - dst.write(buf) or { - return + mut buf := []byte{len: buf_max_len} + for { + len := src.read(mut buf) or { break } + dst.write(buf[..len]) or { + return err + } } unsafe { buf.free()