Skip to content

Commit 25f6d45

Browse files
CoAlloc: slice.rs: Cleanup (of old code already commented out)
1 parent f928542 commit 25f6d45

File tree

1 file changed

+0
-36
lines changed

1 file changed

+0
-36
lines changed

library/alloc/src/slice.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -894,48 +894,12 @@ where
894894
}
895895
};
896896

897-
//<<<<<<< HEAD
898897
let run_alloc_fn = |len: usize| -> *mut sort::TimSortRun {
899898
// SAFETY: Creating the layout is safe as long as merge_sort never calls this with an
900899
// obscene length or 0.
901900
unsafe {
902901
alloc::alloc(alloc::Layout::array::<sort::TimSortRun>(len).unwrap_unchecked())
903902
as *mut sort::TimSortRun
904-
/*=======
905-
// Allocate a buffer to use as scratch memory. We keep the length 0 so we can keep in it
906-
// shallow copies of the contents of `v` without risking the dtors running on copies if
907-
// `is_less` panics. When merging two sorted runs, this buffer holds a copy of the shorter run,
908-
// which will always have length at most `len / 2`.
909-
// `buf` is temporary = not passed around too much => using COOP_PREFERRED=true.
910-
// @FIXME move definitions of `buf` and `runs` down, after while end > 0 {...}, just before they are used. Then benchmark if it makes (cache-related) difference.
911-
let mut buf = Vec::<T, Global, true>::with_capacity(len / 2);
912-
913-
// In order to identify natural runs in `v`, we traverse it backwards. That might seem like a
914-
// strange decision, but consider the fact that merges more often go in the opposite direction
915-
// (forwards). According to benchmarks, merging forwards is slightly faster than merging
916-
// backwards. To conclude, identifying runs by traversing backwards improves performance.
917-
// `runs` is temporary = not passed around too much => using COOP_PREFERRED=true.
918-
let mut runs: Vec<_, Global, true> = vec![];
919-
let mut end = len;
920-
while end > 0 {
921-
// Find the next natural run, and reverse it if it's strictly descending.
922-
let mut start = end - 1;
923-
if start > 0 {
924-
start -= 1;
925-
unsafe {
926-
if is_less(v.get_unchecked(start + 1), v.get_unchecked(start)) {
927-
while start > 0 && is_less(v.get_unchecked(start), v.get_unchecked(start - 1)) {
928-
start -= 1;
929-
}
930-
v[start..end].reverse();
931-
} else {
932-
while start > 0 && !is_less(v.get_unchecked(start), v.get_unchecked(start - 1))
933-
{
934-
start -= 1;
935-
}
936-
}
937-
}
938-
>>>>>>> 6bd68177557 (CoAlloc: Slice: Fixing COOP_PREFERRED)*/
939903
}
940904
};
941905

0 commit comments

Comments
 (0)