-
Notifications
You must be signed in to change notification settings - Fork 113
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
code optimize #218
code optimize #218
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -25,6 +25,7 @@ pub struct FooterProps { | |||||||||||||||||||||||||
|
||||||||||||||||||||||||||
impl Footer { | ||||||||||||||||||||||||||
pub fn render(&self, props: impl Borrow<FooterProps>, area: Rect, buf: &mut Buffer) { | ||||||||||||||||||||||||||
use SortMode::*; | ||||||||||||||||||||||||||
let FooterProps { | ||||||||||||||||||||||||||
total_bytes, | ||||||||||||||||||||||||||
entries_traversed, | ||||||||||||||||||||||||||
|
@@ -39,12 +40,12 @@ impl Footer { | |||||||||||||||||||||||||
Span::from(format!( | ||||||||||||||||||||||||||
"Sort mode: {} Total disk usage: {} Items: {} {progress} ", | ||||||||||||||||||||||||||
match sort_mode { | ||||||||||||||||||||||||||
SortMode::SizeAscending => "size ascending", | ||||||||||||||||||||||||||
SortMode::SizeDescending => "size descending", | ||||||||||||||||||||||||||
SortMode::MTimeAscending => "modified ascending", | ||||||||||||||||||||||||||
SortMode::MTimeDescending => "modified descending", | ||||||||||||||||||||||||||
SortMode::CountAscending => "items ascending", | ||||||||||||||||||||||||||
SortMode::CountDescending => "items descending", | ||||||||||||||||||||||||||
SizeAscending => "size ascending", | ||||||||||||||||||||||||||
SizeDescending => "size descending", | ||||||||||||||||||||||||||
MTimeAscending => "modified ascending", | ||||||||||||||||||||||||||
MTimeDescending => "modified descending", | ||||||||||||||||||||||||||
CountAscending => "items ascending", | ||||||||||||||||||||||||||
CountDescending => "items descending", | ||||||||||||||||||||||||||
Comment on lines
+43
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This unfortunately is not recommended because it throws away some of the safety features of enums inside match expressions. See: https://www.youtube.com/watch?v=8j_FbjiowvE
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for this hint! I wasn't really seeing it this way just yet, but totally see the point (i.e. as enums are changing their variant names, there is then catch-all variants that show up as warnings for 'unused variables'). |
||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
match total_bytes { | ||||||||||||||||||||||||||
Some(b) => format!("{}", format.display(*b)), | ||||||||||||||||||||||||||
|
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.