From 709ccf98b8f646629150c9b1dfa536dd2b905d10 Mon Sep 17 00:00:00 2001 From: joboet Date: Wed, 12 Apr 2023 21:48:12 +0200 Subject: [PATCH] avoid unnecessary `Thread` handle allocation --- library/std/src/sys/pal/unix/locks/queue_rwlock.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys/pal/unix/locks/queue_rwlock.rs b/library/std/src/sys/pal/unix/locks/queue_rwlock.rs index 25a010a1e89..1719a56087a 100644 --- a/library/std/src/sys/pal/unix/locks/queue_rwlock.rs +++ b/library/std/src/sys/pal/unix/locks/queue_rwlock.rs @@ -210,7 +210,8 @@ impl Node { fn prepare(&mut self) { // Fall back to creating an unnamed `Thread` handle to allow locking in // TLS destructors. - self.thread.get_or_init(|| thread_info::current_thread().unwrap_or(Thread::new(None))); + self.thread + .get_or_init(|| thread_info::current_thread().unwrap_or_else(|| Thread::new(None))); self.completed = AtomicBool::new(false); }