From 6cdd2cf577434ca3473c217e8a272ee965ef131f Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sat, 6 Dec 2014 11:17:46 -0800 Subject: [PATCH] Speed up SslStream initialization a bit --- src/ssl/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ssl/mod.rs b/src/ssl/mod.rs index d29d633e..6112bc8d 100644 --- a/src/ssl/mod.rs +++ b/src/ssl/mod.rs @@ -410,7 +410,14 @@ impl SslStream { 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 + } } }