Raku / nqp

NQP
Other
337 stars 131 forks source link

Micro-optimize the sift_down sub in sorted_keys #726

Closed MasterDuke17 closed 3 years ago

MasterDuke17 commented 3 years ago

Exit early if there are 0 or 1 keys to sort, also pull some variable declarations out of a loop to reduce the number of BOOTInts allocated.

lizmat commented 3 years ago

In the sort routine in Rakudo, I've built in special casing for 2-element lists. Would that make sense here as well? It shouldn't have to make any difference for the 3+ elements case, if you change the < 2 condition to < 3 and check for == 2 after that.

MasterDuke17 commented 3 years ago

Right, I thought about that and then forgot to give it a try. I’ll see if it makes a difference.

Sent from my iPhone

On Jun 7, 2021, at 12:31 PM, Elizabeth Mattijsen @.***> wrote:

 In the sort routine in Rakudo, I've built in special casing for 2-element lists. Would that make sense here as well? It shouldn't have to make any difference for the 3+ elements case, if you change the < 2 condition to < 3 and check for == 2 after that.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.