rust/library/std
Jonas Schievink 01ca8299d4
Rollup merge of #77264 - fusion-engineering-forks:skip-local-stdio, r=dtolnay
Only use LOCAL_{STDOUT,STDERR} when set_{print/panic} is used.

The thread local `LOCAL_STDOUT` and `LOCAL_STDERR` are only used by the `test` crate to capture output from tests when running them in the same process in differen threads. However, every program will check these variables on every print, even outside of testing.

This involves allocating a thread local key, and registering a thread local destructor. This can be somewhat expensive.

This change keeps a global flag (`LOCAL_STREAMS`) which will be set to `true` when either of these local streams is used. (So, effectively only in test and benchmark runs.) When this flag is off, these thread locals are not even looked at and therefore will not be initialized on the first output on every thread, which also means no thread local destructors will be registered.

---

Together with https://github.com/rust-lang/rust/pull/77154, this should make output a little bit more efficient.
2020-10-03 00:31:14 +02:00
..
benches
src Rollup merge of #77264 - fusion-engineering-forks:skip-local-stdio, r=dtolnay 2020-10-03 00:31:14 +02:00
tests
build.rs Remove duplicated library links between std and libc 2020-09-21 01:37:15 -07:00
Cargo.toml libary: Forward compiler-builtins "mem" feature 2020-09-27 20:31:06 -07:00