From f8e9d2f0ec1bd91e099e508044981d2cd51ec5f9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 29 Sep 2018 11:07:48 +0300 Subject: [PATCH] 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. --- src/libstd/sync/once.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index ce54726baee2a..17cb614ba11ff 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -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