Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix size unit inconsistency #502

Merged
merged 3 commits into from
Sep 7, 2023
Merged

Fix size unit inconsistency #502

merged 3 commits into from
Sep 7, 2023

Conversation

marcospb19
Copy link
Member

@marcospb19 marcospb19 commented Sep 5, 2023

Fixes #469.

The problem was introduced by the crate ubyte, which was added in #333, reason is explained at #469.

This PR reintroduces @vrmiguel's code at 368a776, but fixed for GiB instead of GB.

The code is a bit arcane with one magical constant and sizes are an approximation, but a good enough one for all real user purposes I can think of.

The humansize crate is too slow for us, even with the no_alloc feature enabled, so I came full-circle to our original implementation instead.

}

let delimiter = 1000_f64;
let exponent = cmp::min((num.ln() / 6.90775).floor() as i32, 4);
Copy link
Member Author

Choose a reason for hiding this comment

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

The constant 6.90775 here is arcane-event-horizon-magic, but it works.

If someone wants to refactor and it ends up as fast as it is, that's great, but I'm not the one who's gonna touch this relic.

I actually wanted MB instead of MiB, but I don't know how to the change the code to do so xD.

@marcospb19 marcospb19 merged commit 9507c4d into main Sep 7, 2023
12 checks passed
@marcospb19 marcospb19 deleted the fix-size-unit-inconsistency branch September 7, 2023 19:12
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.

Progress size unit is inconsistent
1 participant