Optimize: Do not compute lowercase key twice

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-02-28 18:07:25 +01:00
parent ce678d6418
commit ae95022202

View file

@ -42,8 +42,9 @@ pub(crate) fn get_message_header_at_key<P: AsRef<Path>, K: AsRef<str>>(p: P, k:
.filter_map(|hdr| match hdr.get_key() { .filter_map(|hdr| match hdr.get_key() {
Err(e) => Some(Err(e).map_err(Error::from)), Err(e) => Some(Err(e).map_err(Error::from)),
Ok(key) => { Ok(key) => {
trace!("Test: {} == {}", key.to_lowercase(), k.as_ref()); let lower_key = key.to_lowercase();
if key.to_lowercase() == k.as_ref() { trace!("Test: {} == {}", lower_key, k.as_ref());
if lower_key == k.as_ref() {
Some(Ok(hdr)) Some(Ok(hdr))
} else { } else {
None None