Skip to content

Commit 63cb4e3

Browse files
authored
perf: const-ify some logging thread-local variables (#3513)
1 parent 437fc46 commit 63cb4e3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

components-rs/log.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ pub static mut ddog_log_callback: Option<extern "C" fn(CharSlice)> = None;
3838

3939
// Avoid RefCell for performance
4040
std::thread_local! {
41-
static LOGGED_MSGS: RefCell<BTreeSet<String>> = RefCell::default();
42-
static TRACING_GUARDS: RefCell<Option<tracing_core::dispatcher::DefaultGuard>> = RefCell::default();
41+
static LOGGED_MSGS: RefCell<BTreeSet<String>> = const { RefCell::new(BTreeSet::new()) };
42+
static TRACING_GUARDS: RefCell<Option<tracing_core::dispatcher::DefaultGuard>> = const { RefCell::new(None) };
43+
44+
// todo: MSRV 1.85+ make this const with HashMap::with_hasher
4345
static COUNTERS: RefCell<HashMap<Level, u32>> = RefCell::default();
4446
}
4547

0 commit comments

Comments
 (0)