Skip to content

du cleanup#5623

Merged
cakebaker merged 4 commits intouutils:mainfrom
tertsdiepraam:du-cleanup
Dec 8, 2023
Merged

du cleanup#5623
cakebaker merged 4 commits intouutils:mainfrom
tertsdiepraam:du-cleanup

Conversation

@tertsdiepraam
Copy link
Copy Markdown
Collaborator

Related to: nushell/nushell#11040 (comment)

Just some general cleanup of du:

  • Merging imports
  • Not keeping the clap ArgMatches around but put everything in the options structs
  • Split options into traversal en printing options
  • Format sizes without keeping function pointers around

There's more to do, but it's a start :)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 7, 2023

GNU testsuite comparison:

Congrats! The gnu test tests/tail/inotify-dir-recreate is no longer failing!

convert_size,
})
fn new(options: PrintingOptions, summarize: bool) -> UResult<Self> {
Ok(Self { summarize, options })
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Ok(Self { summarize, options })
Ok(Self { options, summarize })

Comment on lines +562 to +570
for &(unit, power) in &UNITS {
let limit = multiplier.pow(power);
if size >= limit {
return format!("{:.1}{}", (size as f64) / (limit as f64), unit);
}
}
if size == 0 {
return "0".to_string();
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for &(unit, power) in &UNITS {
let limit = multiplier.pow(power);
if size >= limit {
return format!("{:.1}{}", (size as f64) / (limit as f64), unit);
}
}
if size == 0 {
return "0".to_string();
}
if size == 0 {
return "0".to_string();
}
for &(unit, power) in &UNITS {
let limit = multiplier.pow(power);
if size >= limit {
return format!("{:.1}{}", (size as f64) / (limit as f64), unit);
}
}

Copy link
Copy Markdown
Contributor

@cakebaker cakebaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for getting rid of those convert_size_* functions.

@cakebaker cakebaker merged commit 7695fe3 into uutils:main Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants