Skip to content

Commit 0d7b749

Browse files
committed
Add missing reserve assume for LLVM
Signed-off-by: Alex Saveau <[email protected]>
1 parent d868bc2 commit 0d7b749

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

library/alloc/src/raw_vec.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ impl<T, A: Allocator> RawVec<T, A> {
308308
if self.needs_to_grow(len, additional) {
309309
do_reserve_and_handle(self, len, additional);
310310
}
311+
unsafe {
312+
// Inform the optimizer that the reservation has succeeded or wasn't needed
313+
intrinsics::assume(!self.needs_to_grow(len, additional));
314+
}
311315
}
312316

313317
/// A specialized version of `reserve()` used only by the hot and
@@ -325,7 +329,7 @@ impl<T, A: Allocator> RawVec<T, A> {
325329
}
326330
unsafe {
327331
// Inform the optimizer that the reservation has succeeded or wasn't needed
328-
core::intrinsics::assume(!self.needs_to_grow(len, additional));
332+
intrinsics::assume(!self.needs_to_grow(len, additional));
329333
}
330334
Ok(())
331335
}
@@ -363,7 +367,7 @@ impl<T, A: Allocator> RawVec<T, A> {
363367
}
364368
unsafe {
365369
// Inform the optimizer that the reservation has succeeded or wasn't needed
366-
core::intrinsics::assume(!self.needs_to_grow(len, additional));
370+
intrinsics::assume(!self.needs_to_grow(len, additional));
367371
}
368372
Ok(())
369373
}

0 commit comments

Comments
 (0)