Skip to content

Commit

Permalink
Simplifying the check of Option<usize>
Browse files Browse the repository at this point in the history
  • Loading branch information
lookbusy1344 committed Apr 3, 2024
1 parent ca37470 commit 681ff6b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ const BUFFER_SIZE: usize = 4096 * 8;
fn hash_file<D: Digest>(filename: &str) -> anyhow::Result<Output<D>> {
let filesize = usize::try_from(file_size(filename)?).ok();

if let Some(size) = filesize {
if size <= BUFFER_SIZE {
// this file is smaller than the buffer size, so we can hash it all at once
return hash_file_whole::<D>(filename);
}
if filesize.map_or(false, |size| size <= BUFFER_SIZE) {
// this file is smaller than the buffer size, so we can hash it all at once
return hash_file_whole::<D>(filename);
}

let file = File::open(filename)?;
Expand Down

0 comments on commit 681ff6b

Please sign in to comment.