Skip to content

Commit

Permalink
Inline nested fn collapse
Browse files Browse the repository at this point in the history
Since merge_sort is generic and collapse isn't, that means calls to
collapse won't be inlined.  inlined. Therefore, we must stick an
`#[inline]` above `fn collapse`.
  • Loading branch information
Stjepan Glavina committed Dec 8, 2016
1 parent c8d73ea commit c0e150a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,7 @@ fn merge_sort<T, F>(v: &mut [T], mut compare: F)
// This function correctly checks invariants for the top four runs. Additionally, if the top
// run starts at index 0, it will always demand a merge operation until the stack is fully
// collapsed, in order to complete the sort.
#[inline]
fn collapse(runs: &[Run]) -> Option<usize> {
let n = runs.len();
if n >= 2 && (runs[n - 1].start == 0 ||
Expand Down

0 comments on commit c0e150a

Please sign in to comment.