Merge two THREAD_INFO.with and following RefCell borrow

This is a bit faster
This commit is contained in:
bjorn3 2021-09-16 15:24:53 +02:00
parent cb14269145
commit 5e7f641a32

View File

@ -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 });
});
}