forked from Deuxfleurs/garage
Optim & refactor
This commit is contained in:
parent
831eb35763
commit
9b118160a8
1 changed files with 11 additions and 8 deletions
|
@ -116,10 +116,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
for (k, vhash) in excluded {
|
for (k, vhash) in excluded {
|
||||||
let _ = self
|
self.todo_remove_if_equal(&k[..], vhash)?;
|
||||||
.data
|
|
||||||
.gc_todo
|
|
||||||
.compare_and_swap::<_, _, Vec<u8>>(k, Some(vhash), None)?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if entries.len() == 0 {
|
if entries.len() == 0 {
|
||||||
|
@ -197,12 +194,17 @@ where
|
||||||
|
|
||||||
for (k, vhash) in deletes {
|
for (k, vhash) in deletes {
|
||||||
self.data.delete_if_equal_hash(&k[..], vhash)?;
|
self.data.delete_if_equal_hash(&k[..], vhash)?;
|
||||||
|
self.todo_remove_if_equal(&k[..], vhash)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn todo_remove_if_equal(&self, key: &[u8], vhash: Hash) -> Result<(), Error> {
|
||||||
let _ = self
|
let _ = self
|
||||||
.data
|
.data
|
||||||
.gc_todo
|
.gc_todo
|
||||||
.compare_and_swap::<_, _, Vec<u8>>(k, Some(vhash), None)?;
|
.compare_and_swap::<_, _, Vec<u8>>(key, Some(vhash), None)?;
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,6 +234,7 @@ where
|
||||||
GcRPC::DeleteIfEqualHash(items) => {
|
GcRPC::DeleteIfEqualHash(items) => {
|
||||||
for (key, vhash) in items.iter() {
|
for (key, vhash) in items.iter() {
|
||||||
self.data.delete_if_equal_hash(&key[..], *vhash)?;
|
self.data.delete_if_equal_hash(&key[..], *vhash)?;
|
||||||
|
self.todo_remove_if_equal(&key[..], *vhash)?;
|
||||||
}
|
}
|
||||||
Ok(GcRPC::Ok)
|
Ok(GcRPC::Ok)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue