-
Notifications
You must be signed in to change notification settings - Fork 69
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
Add summaries to monos sub-command output. #103
Conversation
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.
Wonderful as always @data-pup :)
Feel free to merge once nitpicks are addressed!
analyze/analyze.rs
Outdated
)?; | ||
let approx_potential_savings_percent = | ||
(f64::from(entry.approx_potential_savings)) / (f64::from(items.size())) * 100.0; | ||
// Give an entry representing a generic function and it various |
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.
Nitpick: "Give" -> "Given", "and it various" -> "and its various"
analyze/analyze.rs
Outdated
|
||
let get_size_percent = |x: u32| f64::from(x) / total_size * 100.0; | ||
|
||
let mut rows = vec![TableRow { |
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.
I think this function could return -> impl Iterator<Item = TableRow>
and avoid separate heap allocations for each vec. Not a big deal, though.
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.
Ooh neat! So, I think I took care of this, but I'm not completely sure? I'll hold off on merging this until you have a chance to check on the revised version, but I'd like to try and do it the way you mentioned :)
analyze/analyze.rs
Outdated
size: *size, | ||
size_percent: f64::from(*size) / total_size * 100.0, | ||
size_percent: get_size_percent(*size), | ||
name: name.to_string(), | ||
}].into_iter() |
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.
The vec![..]
will still allocate the heap elements, what we want to do is
use std::iter;
iter::once(TableRow {
...
}).chain(...)
instead of using vec![]
here.
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.
Omg! Okay that's how to do this! I had been having trouble with plain arrays, I didn't know about iter::once
. I'll take care of that today, thanks for the tip!
d260233
to
a0a30da
Compare
Took care of the |
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.
Thansk @data-pup!
Continuing on work for #88, adding summaries/total row summaries to the 'monos' sub-command.