Skip to content

Commit

Permalink
Rollup merge of #118798 - GnomedDev:use-atomicu8-backtrace, r=Nilstrieb
Browse files Browse the repository at this point in the history
Use AtomicU8 instead of AtomicUsize in backtrace.rs

Just a small inefficiency I saw when looking at std sources.
  • Loading branch information
matthiaskrgr authored Jan 19, 2024
2 parents 122b3f9 + 17edbe7 commit 2d828cd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions library/std/src/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ use crate::env;
use crate::ffi::c_void;
use crate::fmt;
use crate::panic::UnwindSafe;
use crate::sync::atomic::{AtomicUsize, Ordering::Relaxed};
use crate::sync::atomic::{AtomicU8, Ordering::Relaxed};
use crate::sync::LazyLock;
use crate::sys_common::backtrace::{lock, output_filename, set_image_base};

Expand Down Expand Up @@ -254,7 +254,7 @@ impl Backtrace {
// Cache the result of reading the environment variables to make
// backtrace captures speedy, because otherwise reading environment
// variables every time can be somewhat slow.
static ENABLED: AtomicUsize = AtomicUsize::new(0);
static ENABLED: AtomicU8 = AtomicU8::new(0);
match ENABLED.load(Relaxed) {
0 => {}
1 => return false,
Expand All @@ -267,7 +267,7 @@ impl Backtrace {
Err(_) => false,
},
};
ENABLED.store(enabled as usize + 1, Relaxed);
ENABLED.store(enabled as u8 + 1, Relaxed);
enabled
}

Expand Down

0 comments on commit 2d828cd

Please sign in to comment.