From a79bfa4f993483b45d2ba5aba4782bf071848938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Romero?= Date: Wed, 30 Sep 2026 19:12:12 +0000 Subject: [PATCH] perf: borrow reply sender identity addresses --- src/compose_controller.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/compose_controller.rs b/src/compose_controller.rs index c3ec6d0f..9e73f2a8 100644 --- a/src/compose_controller.rs +++ b/src/compose_controller.rs @@ -76,8 +76,8 @@ pub(super) fn prepare_message_compose( .sender_identities .iter() .filter(|identity| identity.is_verified()) - .map(|identity| identity.email.trim().to_ascii_lowercase()) - .collect::>(); + .map(|identity| identity.email.trim()) + .collect::>(); let sender_email = source .to .iter() @@ -94,7 +94,11 @@ pub(super) fn prepare_message_compose( }) .unwrap_or_else(|| source.default_sender_email.clone()); let candidates = std::iter::once(&source.from) - .filter(|address| !own_emails.contains(&address.email.trim().to_ascii_lowercase())) + .filter(|address| { + !own_emails + .iter() + .any(|own| own.eq_ignore_ascii_case(address.email.trim())) + }) .chain(source.to.iter()) .chain(source.cc.iter().filter(|_| action == "reply_all")); let recipients = deduplicated_addresses(candidates, &own_emails); @@ -134,14 +138,18 @@ pub(super) fn compose_addresses(addresses: &[flectar_mail_core::models::Address] fn deduplicated_addresses<'a>( addresses: impl IntoIterator, - own_emails: &HashSet, + own_emails: &[&str], ) -> Vec<&'a flectar_mail_core::models::Address> { let mut seen = HashSet::new(); addresses .into_iter() .filter(|address| { let email = address.email.trim().to_ascii_lowercase(); - !email.is_empty() && !own_emails.contains(&email) && seen.insert(email) + !email.is_empty() + && !own_emails + .iter() + .any(|own| own.eq_ignore_ascii_case(&email)) + && seen.insert(email) }) .collect() }