Rust library to generate static websites

perf: cache is_dev()

+8 -1
+8 -1
crates/maudit/src/lib.rs
··· 54 54 // Internal modules 55 55 mod logging; 56 56 57 + use std::sync::LazyLock; 57 58 use std::{env, path::PathBuf}; 58 59 59 60 use build::execute_build; ··· 61 62 use logging::init_logging; 62 63 use route::FullRoute; 63 64 65 + static IS_DEV: LazyLock<bool> = LazyLock::new(|| { 66 + std::env::var("MAUDIT_DEV") 67 + .map(|v| v == "true") 68 + .unwrap_or(false) 69 + }); 70 + 64 71 /// Returns whether Maudit is running in development mode (through `maudit dev`). 65 72 /// 66 73 /// This can be useful to conditionally enable features or logging that should only be active during development. 67 74 /// Oftentimes, this is used to disable some expensive operations that would slow down build times during development. 68 75 pub fn is_dev() -> bool { 69 - env::var("MAUDIT_DEV").map(|v| v == "true").unwrap_or(false) 76 + *IS_DEV 70 77 } 71 78 72 79 #[macro_export]