message: Optimise slightly the get_best method.

This commit is contained in:
Emmanuel Gil Peyrot 2018-05-12 17:42:07 +02:00
parent 6bafe35d2a
commit c72f5819c7

View file

@ -152,12 +152,12 @@ impl Message {
return None; return None;
} }
for lang in preferred_langs { for lang in preferred_langs {
if map.contains_key(lang) { if let Some(body) = map.get(lang) {
return Some((Lang::from(lang), &map[lang])); return Some((Lang::from(lang), body));
} }
} }
if map.contains_key("") { if let Some(body) = map.get("") {
return Some((Lang::new(), &map[""])); return Some((Lang::new(), body));
} }
map.iter().map(|(lang, body)| (lang.clone(), body)).next() map.iter().map(|(lang, body)| (lang.clone(), body)).next()
} }