From 7bafd8a06590bb4574dbf190dee745f27b1e8048 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Thu, 31 Jul 2014 11:46:31 +1000 Subject: [PATCH] Make perf_rainbow.html load ~20x faster by making the file loader read in 8 kB blocks. This also makes the tests run significantly quicker. --- src/components/net/file_loader.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/net/file_loader.rs b/src/components/net/file_loader.rs index a0a7bb074d1..43c3191c600 100644 --- a/src/components/net/file_loader.rs +++ b/src/components/net/file_loader.rs @@ -8,8 +8,7 @@ use std::io; use std::io::File; use servo_util::task::spawn_named; -//FIXME: https://github.com/mozilla/rust/issues/12892 -static READ_SIZE: uint = 1; +static READ_SIZE: uint = 8192; fn read_all(reader: &mut io::Stream, progress_chan: &Sender) -> Result<(), String> { @@ -18,7 +17,12 @@ fn read_all(reader: &mut io::Stream, progress_chan: &Sender) match reader.push_at_least(READ_SIZE, READ_SIZE, &mut buf) { Ok(_) => progress_chan.send(Payload(buf)), Err(e) => match e.kind { - io::EndOfFile => return Ok(()), + io::EndOfFile => { + if buf.len() > 0 { + progress_chan.send(Payload(buf)); + } + return Ok(()); + } _ => return Err(e.desc.to_string()), } }