Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/profile/src/stop_watch.rs')
| -rw-r--r-- | crates/profile/src/stop_watch.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/crates/profile/src/stop_watch.rs b/crates/profile/src/stop_watch.rs index 990b59cad4..0a803959ee 100644 --- a/crates/profile/src/stop_watch.rs +++ b/crates/profile/src/stop_watch.rs @@ -29,11 +29,10 @@ impl StopWatch { // When debugging rust-analyzer using rr, the perf-related syscalls cause it to abort. // We allow disabling perf by setting the env var `RA_DISABLE_PERF`. - use once_cell::sync::Lazy; - static PERF_ENABLED: Lazy<bool> = - Lazy::new(|| std::env::var_os("RA_DISABLE_PERF").is_none()); + use std::sync::OnceLock; + static PERF_ENABLED: OnceLock<bool> = OnceLock::new(); - if *PERF_ENABLED { + if *PERF_ENABLED.get_or_init(|| std::env::var_os("RA_DISABLE_PERF").is_none()) { let mut counter = perf_event::Builder::new() .build() .map_err(|err| eprintln!("Failed to create perf counter: {err}")) |