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
Create closure to do sorting. #281
Conversation
6607174
to
53b1587
Compare
Performance testingUsing the closure:
Without the closure:
Doesn't look like much has changed. |
@Peltoche this is "ready" now. Let me know what I can do to get it merged. |
Hi @aldhsu , A big PR with a lot of change have been merge. I think we are ready now to merge your PR if you succeed to rebase it on top of the current master |
c4b6c84
to
a651851
Compare
Branch is up to date now. Possibly minor effect on performance, recursive sorting around 100k files:
After, branch built with --release
|
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 is way easier to read, thanks!
I think we can improve a little the readability with an enum for the sort order
src/sort.rs
Outdated
let mut sorters: Vec<(bool, Sorter)> = vec![]; | ||
match flags.directory_order { | ||
DirOrderFlag::First => { | ||
sorters.push((false, Box::new(with_dirs_first))); |
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 would be great to replace the boolean with a more explicite enum like:
enum SortOrder {
Default,
Reverse,
}
It would give something like:
sorters.push((SortOrder::Reverse, Box::new(with_dirs_first)));
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.
Oh yeah that totally makes sense and the enum already exists. Addressed in bab0f0e.
bab0f0e
to
20f5c83
Compare
20f5c83
to
ede9735
Compare
@aldhsu this change looks great, can u help to fix the conflict and make this PR happen? |
4ad510b
to
e3bb742
Compare
Codecov Report
@@ Coverage Diff @@
## master #281 +/- ##
==========================================
+ Coverage 66.05% 72.01% +5.95%
==========================================
Files 19 19
Lines 1803 1865 +62
==========================================
+ Hits 1191 1343 +152
+ Misses 612 522 -90
Continue to review full report at Codecov.
|
098185d
to
5ccfee9
Compare
5ccfee9
to
05a6998
Compare
@zwpaper I've updated the PR. I have a bit more knowledge about Rust now and I realized the closure is actually not necessary since closures are just implicit structs. I switched it to store a vec of function pointers on the Core struct instead of a closure, I think this is a bit easier to work with. Before
After
This still definitely makes sorting a bit slower. |
I will try to take a look at it some time this week. |
Hey, thanks a lot. LGTM. |
Was hacking on #277 and realised that splitting the directories out wasn't necessary so jumped to the sorting with a created closure.
Future architecture for sorting:
Core#sort
The test pass but I would like to do some performance testing and complete the second step.