Skip to content

Commit 97678b8

Browse files
authored
Rollup merge of #78621 - solson:inline, r=m-ou-se
Inline Default::default() for atomics Functions like `AtomicUsize::default()` are not cross-crate inlineable before this PR ([see assembly output here](https://play.rust-lang.org/?version=stable&mode=release&edition=2018&gist=e353321766418f759c69fb141d3732f8)), which can lead to unexpected performance issues when initializing a large array using this function, e.g. as seen [here](https://github.com/spacejam/sled/blob/d513996a85875be8c813fd0e30a548b89682289a/src/histogram.rs#L53) which should turn into a simple loop writing zeroes but doesn't. r? @m-ou-se
2 parents 540d474 + e5b1f69 commit 97678b8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/core/src/sync/atomic.rs

+2
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ pub struct AtomicBool {
155155
#[stable(feature = "rust1", since = "1.0.0")]
156156
impl Default for AtomicBool {
157157
/// Creates an `AtomicBool` initialized to `false`.
158+
#[inline]
158159
fn default() -> Self {
159160
Self::new(false)
160161
}
@@ -1212,6 +1213,7 @@ macro_rules! atomic_int {
12121213

12131214
#[$stable]
12141215
impl Default for $atomic_type {
1216+
#[inline]
12151217
fn default() -> Self {
12161218
Self::new(Default::default())
12171219
}

0 commit comments

Comments
 (0)