Skip to content

Commit 279461b

Browse files
committed
use io-close instead of close-file - works (#301)
But: it looks like this issues an additional close call, reducing performance ever so slightly but measurably.
1 parent a28c9b3 commit 279461b

File tree

3 files changed

+41
-65
lines changed

3 files changed

+41
-65
lines changed

Cargo.lock

Lines changed: 37 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

git-worktree/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ thiserror = "1.0.26"
4040
bstr = { version = "0.2.13", default-features = false }
4141

4242
document-features = { version = "0.2.0", optional = true }
43-
close-file = "0.1.0"
43+
io-close = "0.3.7"
4444

4545
[target.'cfg(unix)'.dependencies]
4646
libc = "0.2.119"

git-worktree/src/index/entry.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use std::path::Path;
22
use std::{convert::TryInto, fs::OpenOptions, io::Write, time::Duration};
33

44
use bstr::BStr;
5-
use close_file::Closable;
65
use git_hash::oid;
76
use git_index::Entry;
7+
use io_close::Close;
88

99
use crate::index::checkout::PathCache;
1010
use crate::{index, os};
@@ -70,7 +70,7 @@ where
7070
// NOTE: we don't call `file.sync_all()` here knowing that some filesystems don't handle this well.
7171
// revisit this once there is a bug to fix.
7272
update_fstat(entry, file.metadata()?)?;
73-
file.close().map_err(|err| err.unwrap() /* misnomer, won't panic */)?;
73+
file.close()?;
7474
obj.data.len()
7575
}
7676
git_index::entry::Mode::SYMLINK => {
@@ -91,8 +91,7 @@ where
9191
open_options(p, destination_is_initially_empty, overwrite_existing).open(&dest)
9292
})?;
9393
file.write_all(obj.data)?;
94-
file.close()
95-
.map_err(|err| err.unwrap() /* misnomer for 'into inner' */)?;
94+
file.close()?;
9695
}
9796

9897
update_fstat(entry, std::fs::symlink_metadata(&dest)?)?;

0 commit comments

Comments
 (0)