-
Notifications
You must be signed in to change notification settings - Fork 224
Sort improve #246
Sort improve #246
Conversation
Seems Without this trait, the performance reduces by 16%.
|
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! Left some comments around.
The only way currently I can find to reduce hot path |
Codecov Report
@@ Coverage Diff @@
## main #246 +/- ##
==========================================
- Coverage 76.81% 76.68% -0.13%
==========================================
Files 229 229
Lines 19617 19675 +58
==========================================
+ Hits 15068 15087 +19
- Misses 4549 4588 +39
Continue to review full report at Codecov.
|
for (index, start, len) in self { | ||
v.push((index, start, len)); | ||
|
||
if len + current_len >= limit { |
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 think that this misses the last entries: if the last slice is past limit
, imo it should be modified to be equal to limit - current_len
, so that we do not lose the last items within the slice
I can see that there is some limitations with stable Rust wrt to the ranges and indices. I will take a stab at addressing this here, to see if we can get the remaining performance out of this without the |
I think that #247 addresses the limitations; could you take a look and see what do you think? |
I have also created https://users.rust-lang.org/t/idiomatic-way-to-populate-vector-from-branched-loop/63152 to see if we get good ideas. |
Update: Add |
Ok, I'll take look at that. |
I will go ahead and merge this, and clear up the API in a follow-up PR. Thanks a lot, @sundy-li ! |
Related #245
Changes:
to_vec
function toMergeSortSlices
, this makes iterator reuseable.buffer_from_range
to Index traitcmp(a,b).reverse()
tocmp(b,a)