Francois Gouget : testbot: A small fix and optimization for Collection:: IsEmpty().
Module: tools Branch: master Commit: 57efe43967ef5b82f3587682077bffe6eccafbaa URL: https://source.winehq.org/git/tools.git/?a=commit;h=57efe43967ef5b82f3587682... Author: Francois Gouget <fgouget(a)codeweavers.com> Date: Fri Feb 23 04:40:18 2018 +0100 testbot: A small fix and optimization for Collection::IsEmpty(). Even after loading the collection $self->{Items} could be undefined if no row matched the filters. There is no need to extract the list of keys in order to determine whether the collection is empty. Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- testbot/lib/ObjectModel/Collection.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/testbot/lib/ObjectModel/Collection.pm b/testbot/lib/ObjectModel/Collection.pm index 86dee05..7fa977c 100644 --- a/testbot/lib/ObjectModel/Collection.pm +++ b/testbot/lib/ObjectModel/Collection.pm @@ -420,7 +420,9 @@ sub IsEmpty($) $self->Load(); } - return scalar(keys %{$self->{Items}}) == 0; + # Even though scalar(hash) does not return the number of items in Perl 5.20 + # it returns 0 for an empty hash. + return !$self->{Items} || scalar(%{$self->{Items}}) == 0; } sub CombineKey($@)
participants (1)
-
Alexandre Julliard