3 ms·
I had a specific question about the rust implementation. ordered.sort_by(|&(_, cnt1), &(_, cnt2)| cnt2.cmp(&cnt1)); would produce the same result as what wa
by praveenperera 6y ago
I had a specific question about the rust implementation.
ordered.sort_by(|&(_, cnt1), &(_, cnt2)| cnt2.cmp(&cnt1));
would produce the same result as what was in the blog post:
ordered.sort_by(|&(_, cnt1), &(_, cnt2)| cnt1.cmp(&cnt2).reverse());
But would avoiding the `reverse` call make it any faster, or is that a zero cost abstraction?
- burntsushi 6y agoI didn't check the codegen or anything, but: 1) Yes, almost certainly zero-cost. 2) This isn't a hot part of the program. See also: https://old.reddit.com/r/rust/comments/m5ix0s/performance_comparison_counting_words_in_python/gr099cg/ https://old.reddit.com/r/rust/comments/m5ix0s/performance_co...