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

code optimize #218

Closed
wants to merge 1 commit into from
Closed

code optimize #218

wants to merge 1 commit into from

Conversation

Roxannej
Copy link

No description provided.

@@ -25,6 +25,7 @@ pub struct FooterProps {

impl Footer {
pub fn render(&self, props: impl Borrow<FooterProps>, area: Rect, buf: &mut Buffer) {
use SortMode::*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
use SortMode::*;
use SortMode as E;

Comment on lines +43 to +48
SizeAscending => "size ascending",
SizeDescending => "size descending",
MTimeAscending => "modified ascending",
MTimeDescending => "modified descending",
CountAscending => "items ascending",
CountDescending => "items descending",
Copy link
Contributor

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

Suggested change
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",

Copy link
Owner

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').

Copy link
Owner

@Byron Byron left a 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.

Comment on lines +43 to +48
SizeAscending => "size ascending",
SizeDescending => "size descending",
MTimeAscending => "modified ascending",
MTimeDescending => "modified descending",
CountAscending => "items ascending",
CountDescending => "items descending",
Copy link
Owner

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').

@Byron Byron closed this Jan 14, 2024
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.

3 participants