Francois Gouget : testbot: Optimize the VM comparison method.

Alexandre Julliard julliard at winehq.org
Thu Apr 7 16:07:10 CDT 2022


Module: tools
Branch: master
Commit: 0f125123ca3c99d13ce1632e61a8e58a2806bfcf
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=0f125123ca3c99d13ce1632e61a8e58a2806bfcf

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Thu Apr  7 00:30:58 2022 +0200

testbot: Optimize the VM comparison method.

Using Item::GetColValue() is faster than relying on Item::AUTOLOAD.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 testbot/lib/WineTestBot/VMs.pm | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/testbot/lib/WineTestBot/VMs.pm b/testbot/lib/WineTestBot/VMs.pm
index ee0c1be..2e475b7 100644
--- a/testbot/lib/WineTestBot/VMs.pm
+++ b/testbot/lib/WineTestBot/VMs.pm
@@ -177,16 +177,17 @@ sub InitializeNew($$)
   $self->SUPER::InitializeNew($Collection);
 }
 
+# Sort retired and deleted VMs last
+my %_CmpRole = ("retired" => 1, "deleted" => 2);
+
 sub Compare($$)
 {
   my ($self, $B) = @_;
 
-  # Sort retired and deleted VMs last
-  my %RoleOrders = ("retired" => 1, "deleted" => 2);
-
-  return ($RoleOrders{$self->Role} || 0) <=> ($RoleOrders{$B->Role} || 0) ||
-         $self->SortOrder <=> $B->SortOrder ||
-         $self->Name <=> $B->Name;
+  # Use GetColValue() for performance.
+  return ($_CmpRole{$self->GetColValue("Role")} || 0) <=> ($_CmpRole{$B->GetColValue("Role")} || 0) ||
+         $self->GetColValue("SortOrder") <=> $B->GetColValue("SortOrder") ||
+         $self->GetColValue("Name") <=> $B->GetColValue("Name");
 }
 
 sub HasEnabledRole($)




More information about the wine-cvs mailing list