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

sortMethod simplification. #1535

Merged
merged 4 commits into from
Dec 26, 2023
Merged

sortMethod simplification. #1535

merged 4 commits into from
Dec 26, 2023

Conversation

Michael-Gallo
Copy link
Contributor

The iota enum expression for sortMethod required the same lengthy switch statement in setExpression's eval and setLocalExpression's eval, along with getOptsMap in main to be updated for every sort method. Making sortMethod's underlying representation a string removes the need to have these long and repetitive switch statements and for new sortMethods to require changes outside of dir.sort in nav.go and the const definitions at the top of opts.go

Alternatively, sortMethod can stay as an iota and there can be a map of sortMethods to their string representations.

Copy link
Collaborator

@joelim-work joelim-work left a comment

Choose a reason for hiding this comment

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

Thanks for this patch. From what I can see in the commit history, it looks like from a0e1d4d the sort method actually used to be a string. I'm not sure the reason behind the change though, so I will leave it to @gokcehan to decide before merging.

opts.go Outdated Show resolved Hide resolved
Co-authored-by: Joe Lim <[email protected]>
@gokcehan
Copy link
Owner

@joelim-work I think my rationale for that commit was to have a single line comparison if d.sortType != gOpts.sortType { ... }, but I don't see any reason why we can't simply use strings. As a further cleanup, I'm also in favor of simply getting rid of the sortType struct and having everything under gOpts since the single line comparison is already outdated in this case. Anyway, thank you @Michael-Gallo for the patch and @joelim-work for the review.

@gokcehan gokcehan merged commit e1ab725 into gokcehan:master Dec 26, 2023
4 checks passed
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