summaryrefslogtreecommitdiffstats
path: root/openpgp/src/parse/parse.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-12-20 13:57:43 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-12-20 18:04:56 +0100
commitf5a09e6580914619e7285c107b1aa2af755ca62f (patch)
treed606fe29349c426266d7db5c524ab48ba3a21313 /openpgp/src/parse/parse.rs
parentcf103b49bbaf37783e7d761d3eb06366d9692b89 (diff)
openpgp: Make Container::body just a Vec.
- Vec::with_capacity(0) is guaranteed not to allocate, and the Option encodes no other information. This simplifies code a lot.
Diffstat (limited to 'openpgp/src/parse/parse.rs')
-rw-r--r--openpgp/src/parse/parse.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/openpgp/src/parse/parse.rs b/openpgp/src/parse/parse.rs
index 085b1108..559f2cf6 100644
--- a/openpgp/src/parse/parse.rs
+++ b/openpgp/src/parse/parse.rs
@@ -3626,36 +3626,36 @@ impl <'a> PacketParser<'a> {
},
Packet::CompressedData(p) => {
if rest.len() > 0 {
- if p.body().map(|b| b.len()).unwrap_or(0) > 0 {
- p.body_mut().unwrap().append(&mut rest);
+ if p.body().len() > 0 {
+ p.body_mut().append(&mut rest);
} else {
p.set_body(rest);
}
}
- Ok(p.body().unwrap_or(&b""[..]))
+ Ok(p.body())
},
Packet::SEIP(p) => {
if rest.len() > 0 {
- if p.body().map(|b| b.len()).unwrap_or(0) > 0 {
- p.body_mut().unwrap().append(&mut rest);
+ if p.body().len() > 0 {
+ p.body_mut().append(&mut rest);
} else {
p.set_body(rest);
}
}
- Ok(p.body().unwrap_or(&b""[..]))
+ Ok(p.body())
},
Packet::AED(p) => {
if rest.len() > 0 {
- if p.body().map(|b| b.len()).unwrap_or(0) > 0 {
- p.body_mut().unwrap().append(&mut rest);
+ if p.body().len() > 0 {
+ p.body_mut().append(&mut rest);
} else {
p.set_body(rest);
}
}
- Ok(p.body().unwrap_or(&b""[..]))
+ Ok(p.body())
},
p => {
if rest.len() > 0 {