[tools 1/2] testbot: Provide (quick) read access to Itemref columns.
Francois Gouget
fgouget at codeweavers.com
Tue Apr 26 12:35:55 CDT 2022
Specifically this provides read-only access to the Itemref column(s).
For instance if a task refers to a VM using a VMName field, then one
can now write $Task->VMName instead of $Task->VM->Name.
Incidentally read accesses are also much faster, except for the first
Itemref / Detailref access which has to go through the slow path to
initialize the relevant hashtable.
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
The speedup is about 40% for regular columns.
In the Task + VM example this replaces two slow accesses with a single
faster access, resulting in a ~70% speedup or even more if it avoids
loading the VM object from the database.
---
testbot/lib/ObjectModel/Item.pm | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/testbot/lib/ObjectModel/Item.pm b/testbot/lib/ObjectModel/Item.pm
index c086aec40..d47238182 100644
--- a/testbot/lib/ObjectModel/Item.pm
+++ b/testbot/lib/ObjectModel/Item.pm
@@ -230,10 +230,29 @@ sub AUTOLOAD
# strip fully-qualified portion
my $PropertyName = substr($ObjectModel::Item::AUTOLOAD, rindex($ObjectModel::Item::AUTOLOAD, ':') + 1);
+
+ if (!@_)
+ {
+ # Provide quick read access to all the columns and cached object refs
+ if (defined $self->{ColValues}{$PropertyName})
+ {
+ return $self->{ColValues}{$PropertyName};
+ }
+ elsif (defined $self->{Itemrefs}{$PropertyName})
+ {
+ return $self->{Itemrefs}{$PropertyName};
+ }
+ elsif (defined $self->{Details}{$PropertyName})
+ {
+ return $self->{Details}{$PropertyName};
+ }
+ }
if ($PropertyName eq "DESTROY")
{
return;
}
+
+ # Populate the Itemrefs and Details hashtable if necessary
foreach my $PropertyDescriptor (@{$self->{PropertyDescriptors}})
{
if ($PropertyName eq $PropertyDescriptor->GetName())
--
2.30.2
More information about the wine-devel
mailing list