summaryrefslogtreecommitdiffstats
path: root/openpgp/src/packet
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/packet
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/packet')
-rw-r--r--openpgp/src/packet/signature.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/openpgp/src/packet/signature.rs b/openpgp/src/packet/signature.rs
index 2db99a39..359ea7a5 100644
--- a/openpgp/src/packet/signature.rs
+++ b/openpgp/src/packet/signature.rs
@@ -2316,10 +2316,8 @@ impl crate::packet::Signature {
};
let l = p.serialized_len();
- if size + l <= std::u16::MAX as usize {
- if acc.insert(p.clone()) {
- size += l;
- }
+ if size + l <= std::u16::MAX as usize && acc.insert(p.clone()) {
+ size += l;
}
}
@@ -2343,10 +2341,8 @@ impl crate::packet::Signature {
.filter(|p| eligible(p) && ! p.authenticated() && ! prefer(p)))
{
let l = p.serialized_len();
- if size + l <= std::u16::MAX as usize {
- if acc.insert(p.clone()) {
- size += l;
- }
+ if size + l <= std::u16::MAX as usize && acc.insert(p.clone()) {
+ size += l;
}
}
assert!(size <= std::u16::MAX as usize);