Navigation Menu

Skip to content

Commit

Permalink
Merge two THREAD_INFO.with and following RefCell borrow
Browse files Browse the repository at this point in the history
This is a bit faster
  • Loading branch information
bjorn3 committed Sep 16, 2021
1 parent cb14269 commit 5e7f641
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions library/std/src/sys_common/thread_info.rs
Expand Up @@ -39,6 +39,9 @@ pub fn stack_guard() -> Option<Guard> {
}

pub fn set(stack_guard: Option<Guard>, thread: Thread) {
THREAD_INFO.with(|c| rtassert!(c.borrow().is_none()));
THREAD_INFO.with(move |c| *c.borrow_mut() = Some(ThreadInfo { stack_guard, thread }));
THREAD_INFO.with(move |thread_info| {
let mut thread_info = thread_info.borrow_mut();
rtassert!(thread_info.is_none());
*thread_info = Some(ThreadInfo { stack_guard, thread });
});
}

0 comments on commit 5e7f641

Please sign in to comment.