-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add std.fmt.parseIntSizeSuffix and use for --maxrss #14976
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
Conversation
} | ||
if (without_i.len == 0) return error.InvalidCharacter; | ||
const orders_of_magnitude: usize = switch (without_i[without_i.len - 1]) { | ||
'k', 'K' => 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple ways of doing this doesn't feel necessary, but not sure if hackability is more important in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean the k/K? I did that because the SI and IEC use different capitalizations for the K, which I learned from reading the fmtIntSize docstrings.
lib/std/fmt.zig
Outdated
if (mem.endsWith(u8, buf, "B")) without_b.len -= 1; | ||
var without_i = without_b; | ||
var base: usize = 1000; | ||
if (mem.endsWith(u8, without_b, "i")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sno/if (mem.endsWith(u8, without_b, "i")) {/if (mem.endsWith(u8, without_i, "i")) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't that be inconsistent with the first case? On line 1921, it checks the slice defined before without_b
, so I figured that this line should check the slice defined before without_i
.
lib/std/fmt.zig
Outdated
var without_suffix = without_i; | ||
if (orders_of_magnitude > 0) { | ||
without_suffix.len -= 1; | ||
} else if (without_i.len != without_b.len) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's an i
but no magnitude prefix (see the "2iB" test case)
Fixes #14955