From bd27c3852b91d0be9642de56f719f7183f374acc Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 11 Sep 2007 13:24:59 +0000 Subject: simplify: make find_candidate_packages() the wrapper around find_candidate_packages_() instead of the other way round --- URPM/Resolve.pm | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'URPM/Resolve.pm') diff --git a/URPM/Resolve.pm b/URPM/Resolve.pm index 877339b..032268d 100644 --- a/URPM/Resolve.pm +++ b/URPM/Resolve.pm @@ -22,9 +22,9 @@ sub property2name_op_version { #- Find candidates packages from a require string (or id). #- Takes care of direct choices using the '|' separator. -sub find_candidate_packages { +sub find_candidate_packages_ { my ($urpm, $id_prop, $o_rejected) = @_; - my %packages; + my @packages; foreach (split /\|/, $id_prop) { if (/^\d+$/) { @@ -32,7 +32,7 @@ sub find_candidate_packages { $pkg->flag_skip and next; $pkg->arch eq 'src' || $pkg->is_arch_compat or next; $o_rejected && exists $o_rejected->{$pkg->fullname} and next; - push @{$packages{$pkg->name}}, $pkg; + push @packages, $pkg; } elsif (my $name = property2name($_)) { my $property = $_; foreach (keys %{$urpm->{provides}{$name} || {}}) { @@ -42,16 +42,20 @@ sub find_candidate_packages { $o_rejected && exists $o_rejected->{$pkg->fullname} and next; #- check if at least one provide of the package overlap the property. !$urpm->{provides}{$name}{$_} || $pkg->provides_overlap($property, 1) - and push @{$packages{$pkg->name}}, $pkg; + and push @packages, $pkg; } } } - \%packages; + @packages; } -sub find_candidate_packages_ { +sub find_candidate_packages { my ($urpm, $id_prop, $o_rejected) = @_; - my $packages = find_candidate_packages($urpm, $id_prop, $o_rejected); - map { @$_ } values %$packages; + + my %packages; + foreach (find_candidate_packages_($urpm, $id_prop, $o_rejected)) { + push @{$packages{$_->name}}, $_; + } + \%packages; } sub get_installed_arch { -- cgit v1.2.1