aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2014-12-06 11:17:46 -0800
committerSteven Fackler <[email protected]>2014-12-06 11:17:46 -0800
commit6cdd2cf577434ca3473c217e8a272ee965ef131f (patch)
tree58fb8fc03d4d2a9d42e0cfcdf60ffdfff76e764c /src
parentMerge pull request #110 from Manishearth/patch-1 (diff)
downloadrust-openssl-6cdd2cf577434ca3473c217e8a272ee965ef131f.tar.xz
rust-openssl-6cdd2cf577434ca3473c217e8a272ee965ef131f.zip
Speed up SslStream initialization a bit
Diffstat (limited to 'src')
-rw-r--r--src/ssl/mod.rs9
1 files changed, 8 insertions, 1 deletions
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<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
+ }
}
}