Skip to content

Commit 9d05507

Browse files
Fixing A and COOP_PREFERRED generics. WIP....
1 parent 1f04b07 commit 9d05507

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

library/alloc/src/slice.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,13 +1109,16 @@ where
11091109
// shallow copies of the contents of `v` without risking the dtors running on copies if
11101110
// `is_less` panics. When merging two sorted runs, this buffer holds a copy of the shorter run,
11111111
// which will always have length at most `len / 2`.
1112-
let mut buf = Vec::with_capacity(len / 2);
1112+
// `buf` is temporary = not passed around too much => using COOP_PREFERRED=true.
1113+
// @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.
1114+
let mut buf = Vec::<T, Global, true>::with_capacity(len / 2);
11131115

11141116
// In order to identify natural runs in `v`, we traverse it backwards. That might seem like a
11151117
// strange decision, but consider the fact that merges more often go in the opposite direction
11161118
// (forwards). According to benchmarks, merging forwards is slightly faster than merging
11171119
// backwards. To conclude, identifying runs by traversing backwards improves performance.
1118-
let mut runs = vec![];
1120+
// `runs` is temporary = not passed around too much => using COOP_PREFERRED=true.
1121+
let mut runs: Vec<_, Global, true> = vec![];
11191122
let mut end = len;
11201123
while end > 0 {
11211124
// Find the next natural run, and reverse it if it's strictly descending.

0 commit comments

Comments
 (0)