aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-06-07 17:14:16 +0200
committerAlex Auvolat <alex@adnab.me>2022-06-07 17:14:16 +0200
commit8c6f690fa584e6f1bccc428d2b5525ba219e16c2 (patch)
tree1e4fa81488e61c464279766956ea65df9403afdb
parentcdc03da0b83aeb39d1b16aef252d6b18c5bf1fa9 (diff)
downloadgarage-8c6f690fa584e6f1bccc428d2b5525ba219e16c2.tar.gz
garage-8c6f690fa584e6f1bccc428d2b5525ba219e16c2.zip
less verbose code
-rw-r--r--src/block/rc.rs12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/block/rc.rs b/src/block/rc.rs
index 42cdf241..f82595b7 100644
--- a/src/block/rc.rs
+++ b/src/block/rc.rs
@@ -22,9 +22,7 @@ impl BlockRc {
pub(crate) fn block_incref(&self, tx: &mut db::Transaction, hash: &Hash) -> db::Result<bool> {
let old_rc = RcEntry::parse_opt(tx.get(&self.rc, &hash)?);
match old_rc.increment().serialize() {
- Some(x) => {
- tx.insert(&self.rc, &hash, x)?;
- }
+ Some(x) => tx.insert(&self.rc, &hash, x)?,
None => unreachable!(),
};
Ok(old_rc.is_zero())
@@ -35,12 +33,8 @@ impl BlockRc {
pub(crate) fn block_decref(&self, tx: &mut db::Transaction, hash: &Hash) -> db::Result<bool> {
let new_rc = RcEntry::parse_opt(tx.get(&self.rc, &hash)?).decrement();
match new_rc.serialize() {
- Some(x) => {
- tx.insert(&self.rc, &hash, x)?;
- }
- None => {
- tx.remove(&self.rc, &hash)?;
- }
+ Some(x) => tx.insert(&self.rc, &hash, x)?,
+ None => tx.remove(&self.rc, &hash)?,
};
Ok(matches!(new_rc, RcEntry::Deletable { .. }))
}