Module: tools
Branch: master
Commit: 782d030086c569e3555d08ba45ed3ccd44639764
URL: https://source.winehq.org/git/tools.git/?a=commit;h=782d030086c569e3555d08b…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Wed Apr 13 19:08:50 2022 +0200
testbot: Rename Collection::ItemExists() to HasItem().
Unlike ItemExists(), HasItem() does not imply that a database query is
performed to check whether there is a row for that Item.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/lib/ObjectModel/Collection.pm | 16 ++++++++++------
testbot/lib/WineTestBot/Activity.pm | 8 ++++----
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/testbot/lib/ObjectModel/Collection.pm b/testbot/lib/ObjectModel/Collection.pm
index 93a4502..bec5b1c 100644
--- a/testbot/lib/ObjectModel/Collection.pm
+++ b/testbot/lib/ObjectModel/Collection.pm
@@ -325,7 +325,7 @@ sub GetItem($$)
my ($self, $Key) = @_;
return undef if (!defined $Key);
- return $self->{Items}{$Key} if (defined $self->{Items}{$Key});
+ return $self->{Items}{$Key} if (exists $self->{Items}{$Key});
# The Item is not present in this Collection.
# See if another in-scope Collection loaded it already.
@@ -352,16 +352,20 @@ sub GetItem($$)
=pod
=over 12
-=item C<ItemExists()>
+=item C<HasItem()>
-Returns true if the specified item is present in the collection, that is if it
-either matches the specified filter, or has been explicitly loaded through
-GetItem().
+Returns true if the specified item is present in the collection.
+
+Note that unlike GetItem() this does not query the database to check if it
+contains a matching item. Instead it only checks whether the Collection
+already contains a matching Item, which would mean it was either loaded
+because it either matches the Collection filter, or because of a GetItem()
+call.
=back
=cut
-sub ItemExists($$)
+sub HasItem($$)
{
my ($self, $Key) = @_;
diff --git a/testbot/lib/WineTestBot/Activity.pm b/testbot/lib/WineTestBot/Activity.pm
index b82d265..53aff05 100644
--- a/testbot/lib/WineTestBot/Activity.pm
+++ b/testbot/lib/WineTestBot/Activity.pm
@@ -159,7 +159,7 @@ sub GetActivity($;$)
{
# Ignore retired / deleted VMs
my ($RecordName, $RecordHost) = split / /, $Record->Name;
- next if (!$VMs->ItemExists($RecordName));
+ next if (!$VMs->HasItem($RecordName));
my $StatusVMs = ( $Group->{statusvms} ||= {} );
my $VMStatus = ( $StatusVMs->{$RecordName} ||= {} );
@@ -202,7 +202,7 @@ sub GetActivity($;$)
elsif ($Record->Type eq "vmresult")
{
my ($RecordName, $RecordHost) = split / /, $Record->Name;
- next if (!$VMs->ItemExists($RecordName));
+ next if (!$VMs->HasItem($RecordName));
my $ResultVMs = ( $Group->{resultvms} ||= {} );
my $VMResult = ( $ResultVMs->{$RecordName} ||= {} );
@@ -362,7 +362,7 @@ sub GetStatistics($;$)
foreach my $Task (@{$Tasks->GetItems()})
{
my $HostStats;
- if ($VMs->ItemExists($Task->VM->GetKey()))
+ if ($VMs->HasItem($Task->VM->GetKey()))
{
my $Host = $Task->VM->GetHost();
$HostStats = ($HostsStats->{items}->{$Host} ||= {});
@@ -389,7 +389,7 @@ sub GetStatistics($;$)
{
my $ReportSize = -s $ReportFileName;
_AddFullStat($GlobalStats, "$StepType.size", $ReportSize, undef, $Task);
- if ($VMs->ItemExists($Task->VM->GetKey()))
+ if ($VMs->HasItem($Task->VM->GetKey()))
{
my $VMStats = ($VMsStats->{items}->{$Task->VM->Name} ||= {});
_AddFullStat($VMStats, "report.size", $ReportSize, undef, $Task);