Skip to content

Commit 6ec79e7

Browse files
CoAlloc: Vec: COOP_PREFERRED
1 parent c146757 commit 6ec79e7

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

library/alloc/src/vec/into_iter.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,17 @@ where
131131
// struct and then overwriting &mut self.
132132
// this creates less assembly
133133
self.cap = 0;
134-
self.buf = unsafe { NonNull::new_unchecked(RawVec::NEW.ptr()) };
134+
self.buf = unsafe {
135+
// @FIXME The below if COOP_PREFERRED {..} else {..}
136+
// branching exists, because the following fails. Otherwise we'd have a snowball effect of wide spread of where...Global...
137+
//
138+
// NonNull::new_unchecked(RawVec::<T, Global, COOP_PREFERRED>::NEW.ptr())
139+
if COOP_PREFERRED {
140+
NonNull::new_unchecked(RawVec::<T, Global, true>::NEW.ptr())
141+
} else {
142+
NonNull::new_unchecked(RawVec::<T, Global, false>::NEW.ptr())
143+
}
144+
};
135145
self.ptr = self.buf.as_ptr();
136146
self.end = self.buf.as_ptr();
137147

library/alloc/src/vec/splice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ where
115115
}
116116

117117
/// Private helper methods for `Splice::drop`
118-
impl<T, A: Allocator> Drain<'_, T, A>
118+
impl<T, A: Allocator, const COOP_PREFERRED: bool> Drain<'_, T, A, COOP_PREFERRED>
119119
where
120-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(true)]:,
120+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
121121
{
122122
/// The range from `self.vec.len` to `self.tail_start` contains elements
123123
/// that have been moved out.

0 commit comments

Comments
 (0)