about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2021-09-16 15:24:53 +0200
committerbjorn3 <bjorn3@users.noreply.github.com>2021-09-16 15:24:53 +0200
commit5e7f641a32a01c1cf2b7544020331c1a010e25e0 (patch)
tree9689162909e6d2c28599136cdf14ae0ef19fcbd8
parentcb14269145abef952861b4f73beb78a7ca79e8f6 (diff)
downloadrust-5e7f641a32a01c1cf2b7544020331c1a010e25e0.tar.gz
rust-5e7f641a32a01c1cf2b7544020331c1a010e25e0.zip
Merge two THREAD_INFO.with and following RefCell borrow
This is a bit faster
-rw-r--r--library/std/src/sys_common/thread_info.rs7
1 files 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 c8c0ecceb48..38c9e50009a 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<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 });
+    });
 }