From b59b672937fddbdaa884537626fbd1293c729755 Mon Sep 17 00:00:00 2001 From: exin Date: Sat, 9 Jul 2022 19:49:09 -0500 Subject: [PATCH] Remove Matcher::KeyValue match laziness Closes #316 --- os_info/src/matcher.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/os_info/src/matcher.rs b/os_info/src/matcher.rs index f8acba37..fcc31bc5 100644 --- a/os_info/src/matcher.rs +++ b/os_info/src/matcher.rs @@ -33,10 +33,8 @@ impl Matcher { fn find_by_key<'a>(string: &'a str, key: &str) -> Option<&'a str> { let key = [key, "="].concat(); for line in string.lines() { - if let Some(key_start) = line.find(&key) { - return Some( - line[key_start + key.len()..].trim_matches(|c: char| c == '"' || c.is_whitespace()), - ); + if line.starts_with(&key) { + return Some(line[key.len()..].trim_matches(|c: char| c == '"' || c.is_whitespace())); } }