summaryrefslogtreecommitdiffstats
path: root/urpmf
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-01-18 09:46:07 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-01-18 09:46:07 +0000
commit4be1dc56b5b2e5367459bc97ef10e6a529e28927 (patch)
tree4a4036378109cfade2904bc1f1c5867ffe99b6c2 /urpmf
parent435d92f61744e346fe549006f39aef606333c7e7 (diff)
downloadurpmi-4be1dc56b5b2e5367459bc97ef10e6a529e28927.tar
urpmi-4be1dc56b5b2e5367459bc97ef10e6a529e28927.tar.gz
urpmi-4be1dc56b5b2e5367459bc97ef10e6a529e28927.tar.bz2
urpmi-4be1dc56b5b2e5367459bc97ef10e6a529e28927.tar.xz
urpmi-4be1dc56b5b2e5367459bc97ef10e6a529e28927.zip
- urpmf:
o add special code for --files simple case, it makes urpmf 3x faster for this often used case
Diffstat (limited to 'urpmf')
-rwxr-xr-xurpmf46
1 files changed, 40 insertions, 6 deletions
diff --git a/urpmf b/urpmf
index 68f5581e..edadcedd 100755
--- a/urpmf
+++ b/urpmf
@@ -168,6 +168,19 @@ if ($full) { $qf =~ s/%name\b/%fullname/ }
$urpm->{info} = sub { print STDERR "$_[0]\n" };
$urpm->{log} = sub { print STDERR "$_[0]\n" } if $options{verbose} > 0;
+my $only_simple_files_search;
+if ($qf eq '%name:%files') {
+ if ($::literal) {
+ $only_simple_files_search = $expr !~ /:/;
+ } elsif (@::raw_non_literals == 1) {
+ my $s = $::raw_non_literals[0];
+ $s =~ s!/.*!!; # things after "/" won't match pkg name for sure
+ $only_simple_files_search = $s !~ m![:.*?\[\]]!;
+ }
+ $only_simple_files_search and $urpm->{log}("using fast algorithm");
+}
+
+
my $multitag = '';
my %multitags = map { $_ => 1 } qw(conffiles conflicts files obsoletes provides requires suggests);
my %usedtags;
@@ -223,7 +236,7 @@ my $callback = join("\n",
'0;'),
"}");
-$urpm->{debug}("qf:[$qf]\ncallback:\n$callback") if $urpm->{debug};
+$urpm->{debug}("qf:[$qf]\ncallback:\n$callback") if $urpm->{debug} && !$only_simple_files_search;
our $medium;
$callback = eval $callback;
if ($@) {
@@ -304,10 +317,31 @@ if ($needed_media_info{hdlist}) {
$callback->($urpm, urpm::xml_info_pkg->new($node, undef));
};
$urpm->{log}("getting information from $xml_info_file");
- urpm::xml_info::do_something_with_nodes(
- $xml_info,
- $xml_info_file,
- $cooked_callback,
- );
+ if ($only_simple_files_search) {
+ # special version for speed (3x faster), hopefully fully compatible
+ my $code = sprintf(<<'EOF', $expr);
+ my $F = urpm::xml_info::open_lzma($xml_info_file);
+ my $fn;
+ local $_;
+ while (<$F>) {
+ if (m!^<!) {
+ ($fn) = /fn="(.*)"/;
+ } elsif (%s) {
+ $fn or $urpm->{fatal}("fast algorithm is broken, please report a bug");
+ my $pkg = urpm::xml_info_pkg->new({ fn => $fn });
+ print $pkg->name, ':', $_;
+ }
+ }
+EOF
+ $urpm->{debug} and $urpm->{debug}($code);
+ eval $code;
+ $@ and $urpm->{fatal}(1, "$@");
+ } else {
+ urpm::xml_info::do_something_with_nodes(
+ $xml_info,
+ $xml_info_file,
+ $cooked_callback,
+ );
+ }
}
}