Skip to content

Commit 2fe4df5

Browse files
Make TLS __getit #[inline(always)] on non-Windows
This may improve perf.
1 parent c63c7ba commit 2fe4df5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

std/src/thread/local.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ macro_rules! thread_local {
177177
macro_rules! __thread_local_inner {
178178
// used to generate the `LocalKey` value for const-initialized thread locals
179179
(@key $t:ty, const $init:expr) => {{
180-
#[cfg_attr(not(windows), inline)] // see comments below
180+
#[cfg_attr(not(windows), inline(always))] // see comments below
181181
unsafe fn __getit() -> $crate::option::Option<&'static $t> {
182182
const INIT_EXPR: $t = $init;
183183

@@ -297,7 +297,7 @@ macro_rules! __thread_local_inner {
297297
// gets the pessimistic path for now where it's never inlined.
298298
//
299299
// The issue of "should enable on Windows sometimes" is #84933
300-
#[cfg_attr(not(windows), inline)]
300+
#[cfg_attr(not(windows), inline(always))]
301301
unsafe fn __getit() -> $crate::option::Option<&'static $t> {
302302
#[cfg(all(target_family = "wasm", not(target_feature = "atomics")))]
303303
static __KEY: $crate::thread::__StaticLocalKeyInner<$t> =

0 commit comments

Comments
 (0)