Skip to content

Commit e76afc9

Browse files
committed
du: simplify two if/else constructs
1 parent d3af6fd commit e76afc9

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/uu/du/src/du.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -442,23 +442,19 @@ fn safe_du(
442442
// Handle symlinks with -L option
443443
// For safe traversal with -L, we skip symlinks to directories entirely
444444
// and let the non-safe traversal handle them at the top level
445-
let (entry_stat, is_dir) = if is_symlink && options.dereference == Deref::All {
445+
if is_symlink && options.dereference == Deref::All {
446446
// Skip symlinks to directories when using safe traversal with -L
447447
// They will be handled by regular traversal
448448
continue;
449-
} else {
450-
let is_dir = (lstat.st_mode & S_IFMT) == S_IFDIR;
451-
(lstat, is_dir)
452-
};
449+
}
453450

454-
let file_info = if entry_stat.st_ino != 0 {
455-
Some(FileInfo {
456-
file_id: entry_stat.st_ino as u128,
457-
dev_id: entry_stat.st_dev,
458-
})
459-
} else {
460-
None
461-
};
451+
let is_dir = (lstat.st_mode & S_IFMT) == S_IFDIR;
452+
let entry_stat = lstat;
453+
454+
let file_info = (entry_stat.st_ino != 0).then_some(FileInfo {
455+
file_id: entry_stat.st_ino as u128,
456+
dev_id: entry_stat.st_dev,
457+
});
462458

463459
// For safe traversal, we need to handle stats differently
464460
// We can't use std::fs::Metadata since that requires the full path

0 commit comments

Comments
 (0)