Skip to content

Commit 6680118

Browse files
committed
de-duplicate <unnamed> default thread name
1 parent f2f4e6f commit 6680118

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/thread.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,20 @@ impl<'mir, 'tcx> Thread<'mir, 'tcx> {
134134
}
135135
false
136136
}
137+
138+
/// Get the name of the current thread, or `<unnamed>` if it was not set.
139+
fn thread_name(&self) -> &[u8] {
140+
if let Some(ref thread_name) = self.thread_name {
141+
thread_name
142+
} else {
143+
b"<unnamed>"
144+
}
145+
}
137146
}
138147

139148
impl<'mir, 'tcx> std::fmt::Debug for Thread<'mir, 'tcx> {
140149
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
141-
if let Some(ref name) = self.thread_name {
142-
write!(f, "{}", String::from_utf8_lossy(name))?;
143-
} else {
144-
write!(f, "<unnamed>")?;
145-
}
146-
write!(f, "({:?}, {:?})", self.state, self.join_status)
150+
write!(f, "{}({:?}, {:?})", String::from_utf8_lossy(self.thread_name()), self.state, self.join_status)
147151
}
148152
}
149153

@@ -314,11 +318,7 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
314318

315319
/// Get the name of the active thread.
316320
fn get_thread_name(&self) -> &[u8] {
317-
if let Some(ref thread_name) = self.active_thread_ref().thread_name {
318-
thread_name
319-
} else {
320-
b"<unnamed>"
321-
}
321+
self.active_thread_ref().thread_name()
322322
}
323323

324324
/// Allocate a new blockset id.

0 commit comments

Comments
 (0)