From 80a8b1a45f9739ed632fe28f43037ed0d4157ad1 Mon Sep 17 00:00:00 2001 From: Tarasov Aleksandr <55220741+arabianq@users.noreply.github.com> Date: Fri, 6 Mar 2026 23:00:56 +0300 Subject: [PATCH] perf: optimize value lookup in loop in GetFullStateCommand::execute (#18) Moved the access of `audio_player.input_device_name` outside the loop in `GetFullStateCommand::execute` to avoid repeated field access and Option checking during iteration. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- src/types/commands.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/types/commands.rs b/src/types/commands.rs index 69410c5..69c99d7 100644 --- a/src/types/commands.rs +++ b/src/types/commands.rs @@ -380,13 +380,14 @@ impl Executable for GetFullStateCommand { let mut current_input_nick = String::new(); let audio_player = get_audio_player().await.lock().await; + let current_input_name = audio_player.input_device_name.as_deref(); for device in input_devices { if device.name == "pwsp-virtual-mic" { continue; } - if let Some(current_input_name) = &audio_player.input_device_name { - if device.name == *current_input_name { + if let Some(name) = current_input_name { + if device.name == name { current_input_nick = format!("{} - {}", device.name, device.nick); } }