diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2004-12-29 18:19:18 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2004-12-29 18:19:18 +0000 |
commit | 7bd82322043b89f018d428dc76338ffc96774ec7 (patch) | |
tree | 7a24d8761f4d2c84b4cc1649b2b95dec82e6063d /perl-install | |
parent | 132e49e3690af938a1039a2d1d037bf2687220f8 (diff) | |
download | drakx-backup-do-not-use-7bd82322043b89f018d428dc76338ffc96774ec7.tar drakx-backup-do-not-use-7bd82322043b89f018d428dc76338ffc96774ec7.tar.gz drakx-backup-do-not-use-7bd82322043b89f018d428dc76338ffc96774ec7.tar.bz2 drakx-backup-do-not-use-7bd82322043b89f018d428dc76338ffc96774ec7.tar.xz drakx-backup-do-not-use-7bd82322043b89f018d428dc76338ffc96774ec7.zip |
simplify and speed up computeGroupSize()
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/pkgs.pm | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm index 958983bed..76e306f80 100644 --- a/perl-install/pkgs.pm +++ b/perl-install/pkgs.pm @@ -749,8 +749,14 @@ sub computeGroupSize { } @l; } + my %or_ify_cache; + my $or_ify_cached = sub { + $or_ify_cache{$_[0]} ||= join("\t", or_ify(split("\t", $_[0]))); + }; sub or_clean { - my (@l) = map { [ sort split('&&') ] } @_ or return ''; + my ($flags) = @_; + my @l = split("\t", $flags); + @l = map { [ sort split('&&') ] } @l; my @r; B: while (@l) { my $e = shift @l; @@ -769,19 +775,15 @@ sub computeGroupSize { my %pkgs_with_same_rflags; foreach (@{$packages->{depslist}}) { next if !$_->rate || $_->rate < $min_level || $_->flag_available; - my $flags = join(' ', $_->rflags); + my $flags = join("\t", $_->rflags); next if $flags eq 'FALSE'; push @{$pkgs_with_same_rflags{$flags}}, $_; } foreach my $raw_flags (keys %pkgs_with_same_rflags) { - my $flags = join("\t", my @flags = or_ify(split(' ', $raw_flags))); - my $flag_group = $memo{$flags} ||= or_clean(@flags); - + my $flags = $or_ify_cached->($raw_flags); my @pkgs = @{$pkgs_with_same_rflags{$raw_flags}}; - - $group{$_->name} = $flag_group foreach @pkgs; - + #- determine the packages that will be selected when selecting $p. #- make a fast selection (but potentially erroneous). #- installed and upgrade flags must have been computed (see compute_installed_flags). @@ -824,11 +826,9 @@ sub computeGroupSize { foreach (keys %newSelection) { my $p = $packages->{depslist}[$_] or next; next if $p->flag_selected; #- always installed (accounted in system_size) - my $s = $group{$p->name} || do { - join("\t", or_ify($p->rflags)); - }; + my $s = $group{$p->name} || $or_ify_cached->(join("\t", $p->rflags)); my $m = "$flags\t$s"; - $group{$p->name} = ($memo{$m} ||= or_clean(@flags, split("\t", $s))); + $group{$p->name} = ($memo{$m} ||= or_clean($m)); } } my (%sizes, %pkgs); |