From 2f70a02d4c67089af494c5c8bff336d978bebdeb Mon Sep 17 00:00:00 2001 From: link2xt Date: Sun, 26 Apr 2026 23:29:44 +0200 Subject: [PATCH] perf: set location for all accounts in parallel --- src/accounts.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/accounts.rs b/src/accounts.rs index 99878ec30..af8dfd791 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -543,12 +543,16 @@ impl Accounts { /// /// Returns true if location should still be streamed. pub async fn set_location(&self, latitude: f64, longitude: f64, accuracy: f64) -> Result { - let mut continue_streaming = false; - for account in self.accounts.values() { - if location::set(account, latitude, longitude, accuracy).await? { - continue_streaming = true; - } - } + let continue_streaming = future::try_join_all(self.accounts.iter().map( + |(account_id, account)| async move { + location::set(account, latitude, longitude, accuracy) + .await + .with_context(|| format!("Failed to set location for account {account_id}")) + }, + )) + .await? + .into_iter() + .any(|continue_streaming| continue_streaming); Ok(continue_streaming) }