summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mandriva.org>2009-02-20 16:18:14 +0000
committerThierry Vignaud <tv@mandriva.org>2009-02-20 16:18:14 +0000
commit34db912fe137f76e247bb344cd1604dc71ed92a9 (patch)
tree181c2cc48362fb17e4f1bf6f4bd32e0e574e1eda
parent299583692c50b33466f909dc84a9fe82e9e41d86 (diff)
downloaddrakx-34db912fe137f76e247bb344cd1604dc71ed92a9.tar
drakx-34db912fe137f76e247bb344cd1604dc71ed92a9.tar.gz
drakx-34db912fe137f76e247bb344cd1604dc71ed92a9.tar.bz2
drakx-34db912fe137f76e247bb344cd1604dc71ed92a9.tar.xz
drakx-34db912fe137f76e247bb344cd1604dc71ed92a9.zip
(computeGroupSize) make it shorter through spliting out internal helper functions
-rw-r--r--perl-install/install/pkgs.pm84
1 files changed, 43 insertions, 41 deletions
diff --git a/perl-install/install/pkgs.pm b/perl-install/install/pkgs.pm
index 0b16968d1..b04fb30ce 100644
--- a/perl-install/install/pkgs.pm
+++ b/perl-install/install/pkgs.pm
@@ -423,52 +423,54 @@ sub restoreSelected {
} $l, $flags;
}
-sub computeGroupSize {
- my ($packages, $min_level) = @_;
-
- sub inside {
- my ($l1, $l2) = @_;
- my $i = 0;
- return if @$l1 > @$l2;
- foreach (@$l1) {
- my $c;
- while ($c = $l2->[$i++] cmp $_) {
- return if $c == 1 || $i > @$l2;
- }
- }
- 1;
+sub _inside {
+ my ($l1, $l2) = @_;
+ my $i = 0;
+ return if @$l1 > @$l2;
+ foreach (@$l1) {
+ my $c;
+ while ($c = $l2->[$i++] cmp $_) {
+ return if $c == 1 || $i > @$l2;
+ }
}
+ 1;
+}
- sub or_ify {
- my ($first, @other) = @_;
- my @l = split('\|\|', $first);
- foreach (@other) {
- @l = map {
- my $n = $_;
- map { "$_&&$n" } @l;
- } split('\|\|');
- }
- @l;
+sub _or_ify {
+ my ($first, @other) = @_;
+ my @l = split('\|\|', $first);
+ foreach (@other) {
+ @l = map {
+ my $n = $_;
+ map { "$_&&$n" } @l;
+ } split('\|\|');
+ }
+ @l;
+}
+sub _or_clean {
+ my ($flags) = @_;
+ my @l = split("\t", $flags);
+ @l = map { [ sort split('&&') ] } @l;
+ my @r;
+ B: while (@l) {
+ my $e = shift @l;
+ foreach (@r, @l) {
+ _inside($_, $e) and next B;
+ }
+ push @r, $e;
}
+ join("\t", map { join('&&', @$_) } @r);
+}
+
+
+sub computeGroupSize {
+ my ($packages, $min_level) = @_;
+ my (%group, %memo);
+
my %or_ify_cache;
my $or_ify_cached = sub {
- $or_ify_cache{$_[0]} ||= join("\t", or_ify(split("\t", $_[0])));
+ $or_ify_cache{$_[0]} ||= join("\t", _or_ify(split("\t", $_[0])));
};
- sub or_clean {
- my ($flags) = @_;
- my @l = split("\t", $flags);
- @l = map { [ sort split('&&') ] } @l;
- my @r;
- B: while (@l) {
- my $e = shift @l;
- foreach (@r, @l) {
- inside($_, $e) and next B;
- }
- push @r, $e;
- }
- join("\t", map { join('&&', @$_) } @r);
- }
- my (%group, %memo);
log::l("install::pkgs::computeGroupSize");
my $time = time();
@@ -522,7 +524,7 @@ sub computeGroupSize {
next if $p->flag_selected; #- always installed (accounted in system_size)
my $s = $group{$p->name} || $or_ify_cached->(join("\t", $p->rflags));
my $m = "$flags\t$s";
- $group{$p->name} = ($memo{$m} ||= or_clean($m));
+ $group{$p->name} = ($memo{$m} ||= _or_clean($m));
}
}
my (%sizes, %pkgs);