Skip to content

Commit

Permalink
Only load LOCAL_STREAMS if they are being used
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioBenitez committed Oct 23, 2020
1 parent d0d0e78 commit db15596
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions library/std/src/io/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,11 @@ pub fn set_print(sink: Option<Box<dyn LocalOutput>>) -> Option<Box<dyn LocalOutp
}

pub(crate) fn clone_io() -> (Option<Box<dyn LocalOutput>>, Option<Box<dyn LocalOutput>>) {
// Don't waste time when LOCAL_{STDOUT,STDERR} are definitely None.
if !LOCAL_STREAMS.load(Ordering::Relaxed) {
return (None, None);
}

LOCAL_STDOUT.with(|stdout| {
LOCAL_STDERR.with(|stderr| {
(
Expand Down

0 comments on commit db15596

Please sign in to comment.