Skip to content

Commit db15596

Browse files
committed
Only load LOCAL_STREAMS if they are being used
1 parent d0d0e78 commit db15596

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

library/std/src/io/stdio.rs

+5
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,11 @@ pub fn set_print(sink: Option<Box<dyn LocalOutput>>) -> Option<Box<dyn LocalOutp
963963
}
964964

965965
pub(crate) fn clone_io() -> (Option<Box<dyn LocalOutput>>, Option<Box<dyn LocalOutput>>) {
966+
// Don't waste time when LOCAL_{STDOUT,STDERR} are definitely None.
967+
if !LOCAL_STREAMS.load(Ordering::Relaxed) {
968+
return (None, None);
969+
}
970+
966971
LOCAL_STDOUT.with(|stdout| {
967972
LOCAL_STDERR.with(|stderr| {
968973
(

0 commit comments

Comments
 (0)