less verbose code
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Alex 2022-06-07 17:14:16 +02:00
parent cdc03da0b8
commit 8c6f690fa5
Signed by: lx
GPG key ID: 0E496D15096376BE

View file

@ -22,9 +22,7 @@ impl BlockRc {
pub(crate) fn block_incref(&self, tx: &mut db::Transaction, hash: &Hash) -> db::Result<bool> { 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)?); let old_rc = RcEntry::parse_opt(tx.get(&self.rc, &hash)?);
match old_rc.increment().serialize() { match old_rc.increment().serialize() {
Some(x) => { Some(x) => tx.insert(&self.rc, &hash, x)?,
tx.insert(&self.rc, &hash, x)?;
}
None => unreachable!(), None => unreachable!(),
}; };
Ok(old_rc.is_zero()) 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> { 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(); let new_rc = RcEntry::parse_opt(tx.get(&self.rc, &hash)?).decrement();
match new_rc.serialize() { match new_rc.serialize() {
Some(x) => { Some(x) => tx.insert(&self.rc, &hash, x)?,
tx.insert(&self.rc, &hash, x)?; None => tx.remove(&self.rc, &hash)?,
}
None => {
tx.remove(&self.rc, &hash)?;
}
}; };
Ok(matches!(new_rc, RcEntry::Deletable { .. })) Ok(matches!(new_rc, RcEntry::Deletable { .. }))
} }