Skip to content

Commit

Permalink
Merge pull request #138 from bfffs/redundant-clone
Browse files Browse the repository at this point in the history
Eliminate a redundant clone in Fs::deallocate
  • Loading branch information
asomers committed Jan 20, 2022
2 parents e7c2433 + 6a5c873 commit 59e6701
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions bfffs-core/src/fs.rs
Expand Up @@ -530,12 +530,8 @@ impl Fs {
self.db.fswrite(self.tree, 3, 0, 2, 1,
move |dataset| async move {
let ds = Arc::new(dataset);
// TODO: use an into_inode method instead of as_mut_inode.clone()
let mut inode = ds.get(inode_key).await?
.unwrap()
.as_mut_inode()
.unwrap()
.clone();
let mut inode_value = ds.get(inode_key).await?.unwrap();
let mut inode = inode_value.as_mut_inode().unwrap();
let rs = inode.record_size().unwrap() as u64;
let filesize = inode.size;
offset = filesize.min(offset);
Expand All @@ -547,7 +543,7 @@ impl Fs {
inode.bytes = inode.bytes.saturating_sub(freed);
inode.mtime = now;
inode.ctime = now;
ds.insert(inode_key, FSValue::Inode(inode)).await
ds.insert(inode_key, inode_value).await
.map(drop)
} else {
Ok(())
Expand Down

0 comments on commit 59e6701

Please sign in to comment.