Skip to content

Commit

Permalink
Auto merge of rust-lang#54662 - matklad:once-perf, r=alexcrichton
Browse files Browse the repository at this point in the history
Fix Once perf regression

Because `call_once` is generic, but `is_completed` is not, we need
`#[inline]` annotation to allow LLVM to inline `is_completed` into
`call_once` in downstream crates.

cc https://github.com/rust-lang/rust/pull/53027/files#r221418859
  • Loading branch information
bors committed Oct 1, 2018
2 parents 93efd53 + f8e9d2f commit 0337964
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/libstd/sync/once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ impl Once {
/// assert_eq!(INIT.is_completed(), false);
/// ```
#[unstable(feature = "once_is_completed", issue = "42")]
#[inline]
pub fn is_completed(&self) -> bool {
// An `Acquire` load is enough because that makes all the initialization
// operations visible to us, and, this being a fast path, weaker
Expand Down

0 comments on commit 0337964

Please sign in to comment.