Speed up SslStream initialization a bit

This commit is contained in:
Steven Fackler 2014-12-06 11:17:46 -08:00
parent b8a41f79a1
commit 6cdd2cf577
1 changed files with 8 additions and 1 deletions

View File

@ -410,7 +410,14 @@ impl<S: Stream> SslStream<S> {
stream: stream,
ssl: Arc::new(ssl),
// Maximum TLS record size is 16k
buf: Vec::from_elem(16 * 1024, 0u8)
// We're just using this as a buffer, so there's no reason to pay
// to memset it
buf: {
const CAP: uint = 16 * 1024;
let mut v = Vec::with_capacity(CAP);
unsafe { v.set_len(CAP); }
v
}
}
}