]> git.lizzy.rs Git - rust.git/commit
Optimize creation of buffered readers/writers
authorAlex Crichton <alex@alexcrichton.com>
Mon, 11 Nov 2013 18:08:03 +0000 (10:08 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 11 Nov 2013 18:08:03 +0000 (10:08 -0800)
commitcdf7d63bfce33d2390e3a0a27e01a07f262834e7
treebeb67163fe1f02431c45b8d676d86ce6cd3bc18f
parent4059b5c4b3b8a57a645982b0770d25f0283dfb06
Optimize creation of buffered readers/writers

I was benchmarking rust-http recently, and I saw that 50% of its time was spent
creating buffered readers/writers. Albeit rust-http wasn't using
std::rt::io::buffered, but the same idea applies here. It's much cheaper to
malloc a large region and not initialize it than to set it all to 0. Buffered
readers/writers never use uninitialized data, and their internal buffers are
encapsulated, so any usage of uninitialized slots are an implementation bug in
the readers/writers.
src/libstd/rt/io/buffered.rs