Skip to content

Commit bfb5847

Browse files
committed
perf: const-ify some logging thread-local variables
1 parent 437fc46 commit bfb5847

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

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)