Skip to content

Commit 03498aa

Browse files
committed
Avoid using map_err
1 parent e7f1c8e commit 03498aa

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

library/alloc/src/raw_vec.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,12 @@ impl<T, A: Allocator> RawVec<T, A> {
472472
// `Layout::array` cannot overflow here because it would have
473473
// owerflown earlier when capacity was larger.
474474
let new_layout = Layout::array::<T>(amount).unwrap_unchecked();
475-
self.alloc
476-
.shrink(ptr, layout, new_layout)
477-
.map_err(|_| AllocError { layout: new_layout, non_exhaustive: () })?
475+
// We avoid `map_err` here because it bloats the amount of LLVM IR
476+
// generated.
477+
match self.alloc.shrink(ptr, layout, new_layout) {
478+
Ok(ptr) => ptr,
479+
Err(_) => Err(AllocError { layout: new_layout, non_exhaustive: () })?,
480+
}
478481
};
479482
self.set_ptr(ptr);
480483
Ok(())

0 commit comments

Comments
 (0)