From be690b7a91898eb34987477d6c65330c2499c9a9 Mon Sep 17 00:00:00 2001 From: Fiona Ebner Date: Fri, 10 Nov 2023 14:24:48 +0100 Subject: [PATCH] machine: get current: return early from loop if possible No point iterating through the rest if we already got the current machine. Signed-off-by: Fiona Ebner --- PVE/QemuServer/Machine.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm index 85cfb89c..c9fc9a3d 100644 --- a/PVE/QemuServer/Machine.pm +++ b/PVE/QemuServer/Machine.pm @@ -29,11 +29,12 @@ sub current_from_query_machines { $current = $machine->{name}; # pve-version only exists for the current machine $current .= "+$machine->{'pve-version'}" if $machine->{'pve-version'}; + return $current; } } # fallback to the default machine if current is not supported by qemu - return $current || $default || 'pc'; + return $default || 'pc'; } # this only works if VM is running