mirror of
https://github.com/NotAShelf/microfetch.git
synced 2026-04-13 05:13:50 +00:00
perf: use libc to fetch env vars
This commit is contained in:
parent
8c32f5f408
commit
8376e9d323
3 changed files with 42 additions and 28 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use std::{env, sync::LazyLock};
|
||||
use std::sync::LazyLock;
|
||||
|
||||
pub struct Colors {
|
||||
pub reset: &'static str,
|
||||
|
|
@ -37,8 +37,8 @@ impl Colors {
|
|||
}
|
||||
|
||||
pub static COLORS: LazyLock<Colors> = LazyLock::new(|| {
|
||||
// Check for NO_COLOR once at startup
|
||||
let is_no_color = env::var("NO_COLOR").is_ok();
|
||||
const NO_COLOR: *const libc::c_char = c"NO_COLOR".as_ptr();
|
||||
let is_no_color = unsafe { !libc::getenv(NO_COLOR).is_null() };
|
||||
Colors::new(is_no_color)
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue