Module: tools Branch: master Commit: cc83679b83689e24e92df8060ca9d3d7fe014b54 URL: https://source.winehq.org/git/tools.git/?a=commit;h=cc83679b83689e24e92df806...
Author: Francois Gouget fgouget@codeweavers.com Date: Tue Apr 26 19:35:55 2022 +0200
testbot: Provide (quick) read access to Itemref columns.
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@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
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 c086aec..d472381 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())