diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-01-29 18:42:14 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-01-29 18:42:14 +0100 |
commit | e5ee74691f21f46bdc30556a6b67ecf5f9532ece (patch) | |
tree | 7219e4926d8037da432d4d6027bd5a713f5e4989 | |
parent | 18fa4d0be6285f68b9a163c52bd65955fb3a795b (diff) |
buffered-reader: Use the new as_boxed method.
- This cleanly avoids creating a linked list of references on the
stack that grows every time we call into_inner.
-rw-r--r-- | buffered-reader/src/decompress_bzip2.rs | 2 | ||||
-rw-r--r-- | buffered-reader/src/decompress_deflate.rs | 4 | ||||
-rw-r--r-- | buffered-reader/src/dup.rs | 2 | ||||
-rw-r--r-- | buffered-reader/src/limitor.rs | 2 | ||||
-rw-r--r-- | buffered-reader/src/reserve.rs | 2 | ||||
-rw-r--r-- | openpgp/src/crypto/aead.rs | 2 | ||||
-rw-r--r-- | openpgp/src/crypto/symmetric.rs | 2 | ||||
-rw-r--r-- | openpgp/src/parse/hashed_reader.rs | 2 | ||||
-rw-r--r-- | openpgp/src/parse/partial_body.rs | 2 |
9 files changed, 10 insertions, 10 deletions
diff --git a/buffered-reader/src/decompress_bzip2.rs b/buffered-reader/src/decompress_bzip2.rs index dff2a202..96cf13b0 100644 --- a/buffered-reader/src/decompress_bzip2.rs +++ b/buffered-reader/src/decompress_bzip2.rs @@ -111,7 +111,7 @@ impl<R: BufferedReader<C>, C> BufferedReader<C> for Bzip<R, C> { fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'b>> where Self: 'b { // Strip the outer box. - Some(Box::new(self.reader.reader.into_inner())) + Some(self.reader.reader.into_inner().as_boxed()) } fn cookie_set(&mut self, cookie: C) -> C { diff --git a/buffered-reader/src/decompress_deflate.rs b/buffered-reader/src/decompress_deflate.rs index f31322ac..a54d018c 100644 --- a/buffered-reader/src/decompress_deflate.rs +++ b/buffered-reader/src/decompress_deflate.rs @@ -112,7 +112,7 @@ impl<R: BufferedReader<C>, C> BufferedReader<C> fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'b>> where Self: 'b { // Strip the outer box. - Some(Box::new(self.reader.reader.into_inner())) + Some(self.reader.reader.into_inner().as_boxed()) } fn cookie_set(&mut self, cookie: C) -> C { @@ -234,7 +234,7 @@ impl<R: BufferedReader<C>, C> BufferedReader<C> fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'b>> where Self: 'b { // Strip the outer box. - Some(Box::new(self.reader.reader.into_inner())) + Some(self.reader.reader.into_inner().as_boxed()) } fn cookie_set(&mut self, cookie: C) -> C { diff --git a/buffered-reader/src/dup.rs b/buffered-reader/src/dup.rs index e95971e5..7870050b 100644 --- a/buffered-reader/src/dup.rs +++ b/buffered-reader/src/dup.rs @@ -131,7 +131,7 @@ impl<T: BufferedReader<C>, C> BufferedReader<C> for Dup<T, C> { fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'b>> where Self: 'b { - Some(Box::new(self.reader)) + Some(self.reader.as_boxed()) } fn cookie_set(&mut self, cookie: C) -> C { diff --git a/buffered-reader/src/limitor.rs b/buffered-reader/src/limitor.rs index 59813c82..65478194 100644 --- a/buffered-reader/src/limitor.rs +++ b/buffered-reader/src/limitor.rs @@ -134,7 +134,7 @@ impl<T: BufferedReader<C>, C> BufferedReader<C> for Limitor<T, C> { fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'b>> where Self: 'b { - Some(Box::new(self.reader)) + Some(self.reader.as_boxed()) } fn cookie_set(&mut self, cookie: C) -> C { diff --git a/buffered-reader/src/reserve.rs b/buffered-reader/src/reserve.rs index d9b6f9cc..4c2ec047 100644 --- a/buffered-reader/src/reserve.rs +++ b/buffered-reader/src/reserve.rs @@ -135,7 +135,7 @@ impl<T: BufferedReader<C>, C> BufferedReader<C> for Reserve<T, C> { fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'b>> where Self: 'b { - Some(Box::new(self.reader)) + Some(self.reader.as_boxed()) } fn cookie_set(&mut self, cookie: C) -> C { diff --git a/openpgp/src/crypto/aead.rs b/openpgp/src/crypto/aead.rs index a297b999..ff8a309f 100644 --- a/openpgp/src/crypto/aead.rs +++ b/openpgp/src/crypto/aead.rs @@ -505,7 +505,7 @@ impl<'a> BufferedReader<Cookie> for BufferedReaderDecryptor<'a> { fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<Cookie> + 'b>> where Self: 'b { - Some(Box::new(self.reader.reader.source)) + Some(self.reader.reader.source.as_boxed()) } fn cookie_set(&mut self, cookie: Cookie) -> Cookie { diff --git a/openpgp/src/crypto/symmetric.rs b/openpgp/src/crypto/symmetric.rs index bf9ba25d..2499aa60 100644 --- a/openpgp/src/crypto/symmetric.rs +++ b/openpgp/src/crypto/symmetric.rs @@ -376,7 +376,7 @@ impl<R: BufferedReader<C>, C> BufferedReader<C> fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'b>> where Self: 'b { - Some(Box::new(self.reader.reader.source)) + Some(self.reader.reader.source.as_boxed()) } fn cookie_set(&mut self, cookie: C) -> C { diff --git a/openpgp/src/parse/hashed_reader.rs b/openpgp/src/parse/hashed_reader.rs index 1e46adda..cf252a44 100644 --- a/openpgp/src/parse/hashed_reader.rs +++ b/openpgp/src/parse/hashed_reader.rs @@ -205,7 +205,7 @@ impl<R: BufferedReader<Cookie>> fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<Cookie> + 'b>> where Self: 'b { - Some(Box::new(self.reader)) + Some(self.reader.as_boxed()) } fn cookie_set(&mut self, cookie: Cookie) -> Cookie { diff --git a/openpgp/src/parse/partial_body.rs b/openpgp/src/parse/partial_body.rs index 222e2894..202b1a53 100644 --- a/openpgp/src/parse/partial_body.rs +++ b/openpgp/src/parse/partial_body.rs @@ -386,7 +386,7 @@ impl<T: BufferedReader<Cookie>> BufferedReader<Cookie> fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<Cookie> + 'b>> where Self: 'b { - Some(Box::new(self.reader)) + Some(self.reader.as_boxed()) } fn cookie_set(&mut self, cookie: Cookie) -> Cookie { |