From 5e7f641a32a01c1cf2b7544020331c1a010e25e0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 16 Sep 2021 15:24:53 +0200 Subject: [PATCH] Merge two THREAD_INFO.with and following RefCell borrow This is a bit faster --- library/std/src/sys_common/thread_info.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/library/std/src/sys_common/thread_info.rs b/library/std/src/sys_common/thread_info.rs index c8c0ecceb48cb..38c9e50009af5 100644 --- a/library/std/src/sys_common/thread_info.rs +++ b/library/std/src/sys_common/thread_info.rs @@ -39,6 +39,9 @@ pub fn stack_guard() -> Option { } pub fn set(stack_guard: Option, 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 }); + }); }