perf: Improve custom config OS (#2843)
Related to #2750 and #2751. Moving the OS check before other checks so that there is no performance hit for running the match in the incorrect OS
This commit is contained in:
parent
2acd98248b
commit
5d679d82cc
|
@ -21,6 +21,12 @@ pub fn module<'a>(name: &str, context: &'a Context) -> Option<Module<'a>> {
|
||||||
);
|
);
|
||||||
let config = CustomConfig::load(toml_config);
|
let config = CustomConfig::load(toml_config);
|
||||||
|
|
||||||
|
if let Some(os) = config.os {
|
||||||
|
if os != env::consts::OS && !(os == "unix" && cfg!(unix)) {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut is_match = context
|
let mut is_match = context
|
||||||
.try_begin_scan()?
|
.try_begin_scan()?
|
||||||
.set_files(&config.files)
|
.set_files(&config.files)
|
||||||
|
@ -38,12 +44,6 @@ pub fn module<'a>(name: &str, context: &'a Context) -> Option<Module<'a>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(os) = config.os {
|
|
||||||
if os != env::consts::OS && !(os == "unix" && cfg!(unix)) {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut module = Module::new(name, config.description, Some(toml_config));
|
let mut module = Module::new(name, config.description, Some(toml_config));
|
||||||
|
|
||||||
let parsed = StringFormatter::new(config.format).and_then(|formatter| {
|
let parsed = StringFormatter::new(config.format).and_then(|formatter| {
|
||||||
|
|
Loading…
Reference in New Issue