From b639e80bff21601098131b24a03620cb989abc14 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 21 Feb 2026 18:16:47 +0000 Subject: [PATCH] perf: optimize enrollment subscription by avoiding unnecessary string cloning Refactor `enroll_fingerprint_process` to accept references (`&zbus::zvariant::OwnedObjectPath`, `&str`) instead of owned types for `path`, `finger_name`, and `username`. This eliminates the need to clone `String` and `OwnedObjectPath` data on every iteration of the enrollment subscription loop in `AppModel`. * Modified `src/app/fprint.rs`: Updated `enroll_fingerprint_process` signature. * Modified `src/app/mod.rs`: Updated subscription logic to pass references. --- src/app/fprint.rs | 10 +++++----- src/app/mod.rs | 9 +++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/app/fprint.rs b/src/app/fprint.rs index 21777e1..ea25b6f 100644 --- a/src/app/fprint.rs +++ b/src/app/fprint.rs @@ -92,9 +92,9 @@ pub async fn clear_all_fingers_dbus( pub async fn enroll_fingerprint_process( connection: zbus::Connection, - path: zbus::zvariant::OwnedObjectPath, - finger_name: String, - username: String, + path: &zbus::zvariant::OwnedObjectPath, + finger_name: &str, + username: &str, output: &mut S, ) -> zbus::Result<()> where @@ -107,7 +107,7 @@ where .await?; // Claim device - match device.claim(&username).await { + match device.claim(username).await { Ok(_) => {} Err(e) => return Err(e), }; @@ -119,7 +119,7 @@ where let _ = output.send(Message::EnrollStart(total_stages)).await; // Start enrollment - if let Err(e) = device.enroll_start(&finger_name).await { + if let Err(e) = device.enroll_start(finger_name).await { let _ = device.release().await; return Err(e); } diff --git a/src/app/mod.rs b/src/app/mod.rs index 9ef3072..49a58c1 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -299,14 +299,11 @@ impl cosmic::Application for AppModel { std::any::TypeId::of::(), cosmic::iced::stream::channel(100, move |mut output| async move { // Implement enrollment stream here - let username = (*user.username).clone(); - let device_path = (*device_path).clone(); - let finger_name = (*finger_name).clone(); match enroll_fingerprint_process( connection, - device_path, - finger_name, - username, + &device_path, + &finger_name, + &user.username, &mut output, ) .await