Reduce again the number of match calls (#7815)

- Reduce the number of match calls (see commit messages)
- A few miscellaneous improvements
This commit is contained in:
Hofer-Julian
2023-01-24 12:23:42 +01:00
committed by GitHub
parent 0bb2e47c98
commit 41306aa7e0
49 changed files with 467 additions and 634 deletions

View File

@@ -484,15 +484,17 @@ impl EngineState {
serde_json::to_string_pretty(&decl.signature())
.map(|signature| {
// Extracting the possible path to the shell used to load the plugin
let shell_str = match shell {
Some(path) => format!(
"-s {}",
path.to_str().expect(
"shell path was checked during registration as a str"
let shell_str = shell
.as_ref()
.map(|path| {
format!(
"-s {}",
path.to_str().expect(
"shell path was checked during registration as a str"
)
)
),
None => "".into(),
};
})
.unwrap_or_default();
// Each signature is stored in the plugin file with the shell and signature
// This information will be used when loading the plugin
@@ -1020,9 +1022,10 @@ impl TypeScope {
}
pub fn add_type(&mut self, input: Type) {
match self.outputs.last_mut() {
Some(v) => v.push(input),
None => self.outputs.push(vec![input]),
if let Some(v) = self.outputs.last_mut() {
v.push(input)
} else {
self.outputs.push(vec![input])
}
}

View File

@@ -225,9 +225,10 @@ impl OverlayFrame {
}
pub fn get_decl(&self, name: &[u8], input: &Type) -> Option<DeclId> {
match self.decls.get(&(name, input) as &dyn DeclKey) {
Some(decl) => Some(*decl),
None => self.decls.get(&(name, &Type::Any) as &dyn DeclKey).cloned(),
if let Some(decl) = self.decls.get(&(name, input) as &dyn DeclKey) {
Some(*decl)
} else {
self.decls.get(&(name, &Type::Any) as &dyn DeclKey).cloned()
}
}
}