optimization

This commit is contained in:
Valerie Wolfe 2021-06-17 23:06:31 -04:00
parent 0cc0aad8b5
commit bbb73290ef

View file

@ -63,20 +63,20 @@ impl Config {
pub fn get(&self, section: &str, key: &str) -> Option<String> { pub fn get(&self, section: &str, key: &str) -> Option<String> {
let mut output: Option<String> = None; let mut output: Option<String> = None;
if self.local.is_some() { if self.local.is_some() {
output = self.local.clone().unwrap().get(section, key); output = self.local.as_ref().unwrap().get(section, key);
} }
if output.is_none() && self.global.is_some() { if output.is_none() && self.global.is_some() {
output = self.global.clone().unwrap().get(section, key); output = self.global.as_ref().unwrap().get(section, key);
} }
return output; return output;
} }
pub fn getbool(&self, section: &str, key: &str) -> Result<Option<bool>, String> { pub fn getbool(&self, section: &str, key: &str) -> Result<Option<bool>, String> {
let mut output = Ok(None); let mut output = Ok(None);
if self.local.is_some() { if self.local.is_some() {
output = self.local.clone().unwrap().getbool(section, key); output = self.local.as_ref().unwrap().getbool(section, key);
} }
if output.clone().ok().is_none() && self.global.is_some() { if output.clone().ok().is_none() && self.global.is_some() {
output = self.global.clone().unwrap().getbool(section, key); output = self.global.as_ref().unwrap().getbool(section, key);
} }
return output; return output;
} }