Skip to content

Commit 5e7f641

Browse files
committed
Merge two THREAD_INFO.with and following RefCell borrow
This is a bit faster
1 parent cb14269 commit 5e7f641

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

library/std/src/sys_common/thread_info.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ pub fn stack_guard() -> Option<Guard> {
3939
}
4040

4141
pub fn set(stack_guard: Option<Guard>, thread: Thread) {
42-
THREAD_INFO.with(|c| rtassert!(c.borrow().is_none()));
43-
THREAD_INFO.with(move |c| *c.borrow_mut() = Some(ThreadInfo { stack_guard, thread }));
42+
THREAD_INFO.with(move |thread_info| {
43+
let mut thread_info = thread_info.borrow_mut();
44+
rtassert!(thread_info.is_none());
45+
*thread_info = Some(ThreadInfo { stack_guard, thread });
46+
});
4447
}

0 commit comments

Comments
 (0)