diff options
author | bnewbold <bnewbold@robocracy.org> | 2016-06-03 01:16:08 -0400 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2016-06-03 01:16:08 -0400 |
commit | f68ff03d06a489114989b501e7e82cba1525f99e (patch) | |
tree | 473a994b9d15c3c32a8006e476755f2ffa38721b /src/common.rs | |
parent | a4d30ec5255a188ad9c359c52fd74d8091721e62 (diff) | |
download | ucp-f68ff03d06a489114989b501e7e82cba1525f99e.tar.gz ucp-f68ff03d06a489114989b501e7e82cba1525f99e.zip |
optimize by increasing CHUNK_SIZE to 16KB (from 4KB)
Diffstat (limited to 'src/common.rs')
-rw-r--r-- | src/common.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/common.rs b/src/common.rs index facd527..1900385 100644 --- a/src/common.rs +++ b/src/common.rs @@ -13,6 +13,8 @@ fn fake_io_error(msg: &str) -> io::Result<()> { Err(io::Error::new(io::ErrorKind::Other, msg)) } +const CHUNK_SIZE: usize = 1024*16; + pub fn source_files<S: Read + Write>(stream: &mut S, file_path: &str, recursive: bool) -> io::Result<()> { println!("SOURCE FILE: {}", file_path); if recursive { unimplemented!(); } @@ -38,7 +40,7 @@ pub fn source_files<S: Read + Write>(stream: &mut S, file_path: &str, recursive: _ => { return fake_io_error("Unexpected status char!"); }, }; - let mut buf = [0; 4096]; + let mut buf = [0; CHUNK_SIZE]; let mut sent: usize = 0; while sent < flen { let rlen = try!(f.read(&mut buf)); @@ -83,7 +85,7 @@ pub fn sink_files<S: Read + Write>(stream: &mut S, file_path: &str, recursive: b let mut f = try!(File::create(file_path)); let mut byte_buf = [0; 1]; - let mut buf = [0; 4096]; + let mut buf = [0; CHUNK_SIZE]; try!(stream.read_exact(&mut byte_buf)); let msg_type = byte_buf[0]; match msg_type as char { |