Small syntax changes
This commit is contained in:
parent
a77efd7ca6
commit
0ab21e780e
6 changed files with 18 additions and 32 deletions
|
@ -10,9 +10,7 @@ use std::sync::{Arc, RwLock};
|
|||
use heed::types::ByteSlice;
|
||||
use heed::{BytesDecode, Env, RoTxn, RwTxn, UntypedDatabase as Database};
|
||||
|
||||
use crate::{
|
||||
Db, Error, IDb, ITx, ITxFn, Result, TxError, TxFnResult, TxResult, Value, ValueIter,
|
||||
};
|
||||
use crate::{Db, Error, IDb, ITx, ITxFn, Result, TxError, TxFnResult, TxResult, Value, ValueIter};
|
||||
|
||||
pub use heed;
|
||||
|
||||
|
|
|
@ -9,9 +9,7 @@ use sled::transaction::{
|
|||
UnabortableTransactionError,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
Db, Error, IDb, ITx, ITxFn, Result, TxError, TxFnResult, TxResult, Value, ValueIter,
|
||||
};
|
||||
use crate::{Db, Error, IDb, ITx, ITxFn, Result, TxError, TxFnResult, TxResult, Value, ValueIter};
|
||||
|
||||
pub use sled;
|
||||
|
||||
|
|
|
@ -67,13 +67,12 @@ impl Repair {
|
|||
let mut i = 0;
|
||||
|
||||
while !*must_exit.borrow() {
|
||||
let item_bytes = {
|
||||
let (k, v) = match self.garage.version_table.data.store.get_gt(pos)? {
|
||||
Some(pair) => pair,
|
||||
None => break,
|
||||
};
|
||||
let item_bytes = match self.garage.version_table.data.store.get_gt(pos)? {
|
||||
Some((k, v)) => {
|
||||
pos = k;
|
||||
v
|
||||
}
|
||||
None => break,
|
||||
};
|
||||
|
||||
i += 1;
|
||||
|
@ -119,13 +118,12 @@ impl Repair {
|
|||
let mut i = 0;
|
||||
|
||||
while !*must_exit.borrow() {
|
||||
let item_bytes = {
|
||||
let (k, v) = match self.garage.block_ref_table.data.store.get_gt(pos)? {
|
||||
Some(pair) => pair,
|
||||
None => break,
|
||||
};
|
||||
let item_bytes = match self.garage.block_ref_table.data.store.get_gt(pos)? {
|
||||
Some((k, v)) => {
|
||||
pos = k;
|
||||
v
|
||||
}
|
||||
None => break,
|
||||
};
|
||||
|
||||
i += 1;
|
||||
|
|
|
@ -243,10 +243,7 @@ where
|
|||
|
||||
pub(crate) fn delete_if_equal(self: &Arc<Self>, k: &[u8], v: &[u8]) -> Result<bool, Error> {
|
||||
let removed = self.store.db().transaction(|mut tx| {
|
||||
let remove = match tx.get(&self.store, k)? {
|
||||
Some(cur_v) if cur_v == v => true,
|
||||
_ => false,
|
||||
};
|
||||
let remove = matches!(tx.get(&self.store, k)?, Some(cur_v) if cur_v == v => true);
|
||||
if remove {
|
||||
tx.remove(&self.store, k)?;
|
||||
tx.insert(&self.merkle_todo, k, vec![])?;
|
||||
|
|
|
@ -383,10 +383,8 @@ impl GcTodoEntry {
|
|||
pub(crate) fn remove_if_equal(&self, gc_todo_tree: &db::Tree) -> Result<(), Error> {
|
||||
let key = self.todo_table_key();
|
||||
gc_todo_tree.db().transaction(|mut tx| {
|
||||
let remove = match tx.get(gc_todo_tree, &key)? {
|
||||
Some(ov) if ov == self.value_hash.as_slice() => true,
|
||||
_ => false,
|
||||
};
|
||||
let remove =
|
||||
matches!(tx.get(gc_todo_tree, &key)? Some(ov) if ov == self.value_hash.as_slice());
|
||||
if remove {
|
||||
tx.remove(gc_todo_tree, &key)?;
|
||||
}
|
||||
|
|
|
@ -140,10 +140,7 @@ where
|
|||
.transaction(|mut tx| self.update_item_rec(&mut tx, k, &khash, &key, new_vhash))?;
|
||||
|
||||
let deleted = self.data.merkle_todo.db().transaction(|mut tx| {
|
||||
let remove = match tx.get(&self.data.merkle_todo, k)? {
|
||||
Some(ov) if ov == vhash_by => true,
|
||||
_ => false,
|
||||
};
|
||||
let remove = matches!(tx.get(&self.data.merkle_todo, k)?, Some(ov) if ov == vhash_by);
|
||||
if remove {
|
||||
tx.remove(&self.data.merkle_todo, k)?;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue