-
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
Conversation
@@ -25,6 +25,7 @@ pub struct FooterProps { | |||
|
|||
impl Footer { | |||
pub fn render(&self, props: impl Borrow<FooterProps>, area: Rect, buf: &mut Buffer) { | |||
use SortMode::*; |
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.
use SortMode::*; | |
use SortMode as E; |
SizeAscending => "size ascending", | ||
SizeDescending => "size descending", | ||
MTimeAscending => "modified ascending", | ||
MTimeDescending => "modified descending", | ||
CountAscending => "items ascending", | ||
CountDescending => "items descending", |
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.
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
SizeAscending => "size ascending", | |
SizeDescending => "size descending", | |
MTimeAscending => "modified ascending", | |
MTimeDescending => "modified descending", | |
CountAscending => "items ascending", | |
CountDescending => "items descending", | |
E::SizeAscending => "size ascending", | |
E::SizeDescending => "size descending", | |
E::MTimeAscending => "modified ascending", | |
E::MTimeDescending => "modified descending", | |
E::CountAscending => "items ascending", | |
E::CountDescending => "items descending", |
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.
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').
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 don't perceive this as optimization, but that might just be an issue with the wording.
However, I don't think shortening lines is important enough to merge this PR, after all, the look doesn't change.
Thanks for your understanding.
SizeAscending => "size ascending", | ||
SizeDescending => "size descending", | ||
MTimeAscending => "modified ascending", | ||
MTimeDescending => "modified descending", | ||
CountAscending => "items ascending", | ||
CountDescending => "items descending", |
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.
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').
No description provided.