Skip to content

Commit

Permalink
Use const {} for the THREAD_INFO thread local
Browse files Browse the repository at this point in the history
This makes accesses to it cheaper
  • Loading branch information
bjorn3 committed Sep 16, 2021
1 parent f78cd44 commit a8bb3bc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion library/std/src/sys_common/thread_info.rs
@@ -1,4 +1,5 @@
#![allow(dead_code)] // stack_guard isn't used right now on all platforms
#![allow(unused_unsafe)] // thread_local with `const {}` triggers this liny

use crate::cell::RefCell;
use crate::sys::thread::guard::Guard;
Expand All @@ -9,7 +10,7 @@ struct ThreadInfo {
thread: Thread,
}

thread_local! { static THREAD_INFO: RefCell<Option<ThreadInfo>> = RefCell::new(None) }
thread_local! { static THREAD_INFO: RefCell<Option<ThreadInfo>> = const { RefCell::new(None) } }

impl ThreadInfo {
fn with<R, F>(f: F) -> Option<R>
Expand Down

0 comments on commit a8bb3bc

Please sign in to comment.