summaryrefslogtreecommitdiffstats
path: root/openpgp/src/serialize/stream.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-09-27 18:49:32 +0300
committerLars Wirzenius <liw@sequoia-pgp.org>2021-09-30 08:31:12 +0300
commitd7cb7da07661ce42c36ba2dd4bc0edcad11a7e81 (patch)
tree830a8bcde3f3b6537af99976d5e8385bf4a42e83 /openpgp/src/serialize/stream.rs
parent28f1cef827fc738f48b723974f4fe4229ad6dc67 (diff)
Join nested if statements with logical and into one statement
Instead of this: if foo { if bar { ... } } do this: if foo && bar { ... } Nesting statements implies a more complicated code structure than it really is. Thus it's arguably simpler to write a combined condition by joining the two conditions with a logical and operation. Found by clippy lint collapsible_if: https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
Diffstat (limited to 'openpgp/src/serialize/stream.rs')
-rw-r--r--openpgp/src/serialize/stream.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/openpgp/src/serialize/stream.rs b/openpgp/src/serialize/stream.rs
index 53068489..cbfa1117 100644
--- a/openpgp/src/serialize/stream.rs
+++ b/openpgp/src/serialize/stream.rs
@@ -1409,12 +1409,10 @@ impl<'a> Write for Signer<'a> {
// later, we will hash it then. Otherwise, it is
// implicitly omitted when the signer is finalized.
self.hash_stash.extend_from_slice(&data[l..]);
+ } else if self.template.typ() == SignatureType::Text {
+ crate::parse::hash_update_text(&mut self.hash, data);
} else {
- if self.template.typ() == SignatureType::Text {
- crate::parse::hash_update_text(&mut self.hash, data);
- } else {
- self.hash.update(data);
- }
+ self.hash.update(data);
}
self.position += amount as u64;
}