1
Fork 0

Only load LOCAL_STREAMS if they are being used

This commit is contained in:
Sergio Benitez 2020-10-22 03:22:13 -07:00
parent d0d0e78208
commit db15596c57

View file

@ -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| {
(