message: Optimise slightly the get_best method.
This commit is contained in:
parent
6bafe35d2a
commit
c72f5819c7
1 changed files with 4 additions and 4 deletions
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue