1
Fork 0
rust/library/alloc
Matthias Krüger 8d52aae968
Rollup merge of #136089 - jwong101:box-default-debug-stack-usage, r=Amanieu
Reduce `Box::default` stack copies in debug mode

The `Box::new(T::default())` implementation of `Box::default` only
had two stack copies in debug mode, compared to the current version,
which has four. By avoiding creating any `MaybeUninit<T>`'s and just writing
`T` directly to the `Box` pointer, the stack usage in debug mode remains
the same as the old version.

Another option would be to mark `Box::write` as `#[inline(always)]`,
and change it's implementation to to avoid calling `MaybeUninit::write`
(which creates a `MaybeUninit<T>` on the stack) and to use `ptr::write` instead.

Fixes: #136043
2025-02-21 12:45:22 +01:00
..
benches library: Update rand to 0.9.0 2025-02-13 12:20:55 -08:00
src Rollup merge of #136089 - jwong101:box-default-debug-stack-usage, r=Amanieu 2025-02-21 12:45:22 +01:00
tests Rollup merge of #120580 - HTGAzureX1212:HTGAzureX1212/issue-45795, r=m-ou-se 2025-02-19 21:16:01 +01:00
Cargo.toml library: Update rand to 0.9.0 2025-02-13 12:20:55 -08:00