Skip to content

Commit

Permalink
[NFCI] Use scope rather than drop for file lifetime
Browse files Browse the repository at this point in the history
Addresses a review comment in #107.
  • Loading branch information
peterwaller-arm committed Aug 8, 2023
1 parent 2c830d4 commit efb9a01
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/repo/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,12 @@ impl Repository {

let pack_entries = run_in_parallel(threads, files.into_iter(), |file_path| {
let mut fd = File::open(&file_path)?;
let mut buf = vec![];
fd.read_to_end(&mut buf)?;
let mode = fd.metadata()?.permissions().mode();
drop(fd);
let (buf, mode) = {
let mut buf = vec![];
fd.read_to_end(&mut buf)?;
let mode = fd.metadata()?.permissions().mode();
(buf, mode)
};
let mut checksum = [0u8; 20];
let mut hasher = Sha1::new();
hasher.input(&buf);
Expand Down

0 comments on commit efb9a01

Please sign in to comment.