X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FBugs.pm;h=93967e2cb2f8b885a022cfa9cfe2e5cf7eb3d89f;hb=00449b8919283ee68775aecb2fc91da6ac463d20;hp=5ae0afa9faf39e7d4bf238ecfaea78a1f4562451;hpb=356bc18cec24cb1d87ea62f222a0b30ff817855d;p=debbugs.git diff --git a/Debbugs/Bugs.pm b/Debbugs/Bugs.pm index 5ae0afa..93967e2 100644 --- a/Debbugs/Bugs.pm +++ b/Debbugs/Bugs.pm @@ -37,6 +37,7 @@ incomplete) to slowest (and most complete).] use warnings; use strict; +use feature 'state'; use vars qw($VERSION $DEBUG %EXPORT_TAGS @EXPORT_OK @EXPORT); use Exporter qw(import); @@ -58,7 +59,7 @@ use Debbugs::Packages qw(getsrcpkgs getpkgsrc); use Debbugs::Common qw(getparsedaddrs package_maintainer getmaintainers make_list hash_slice); use Fcntl qw(O_RDONLY); use MLDBM qw(DB_File Storable); -use List::Util qw(first); +use List::AllUtils qw(first); use Carp; =head2 get_bugs @@ -152,7 +153,7 @@ bug should not. =cut -my $_non_search_key_regex = qr/^(bugs|archive|usertags|schema)$/; +state $_non_search_key_regex = qr/^(bugs|archive|usertags|schema)$/; my %_get_bugs_common_options = (package => {type => SCALAR|ARRAYREF, @@ -206,7 +207,7 @@ my %_get_bugs_common_options = ); -my $_get_bugs_options = {%_get_bugs_common_options}; +state $_get_bugs_options = {%_get_bugs_common_options}; sub get_bugs{ my %param = validate_with(params => \@_, spec => $_get_bugs_options, @@ -399,7 +400,7 @@ searches. =cut -my $_get_bugs_by_idx_options = +state $_get_bugs_by_idx_options = {hash_slice(%_get_bugs_common_options, (qw(package submitter severity tag archive), qw(owner src maint bugs correspondent), @@ -487,7 +488,7 @@ searches. =cut -my $_get_bugs_by_db_options = +state $_get_bugs_by_db_options = {hash_slice(%_get_bugs_common_options, (qw(package submitter severity tag archive), qw(owner src maint bugs correspondent), @@ -509,24 +510,24 @@ sub get_bugs_by_db{ $rs = $rs->search({-or => {map 'bin_package.'}}) } if (exists $param{severity}) { - $rs = $rs->search({-or => {map {('severity.severity' => $_)} - make_list($param{severity})}, + $rs = $rs->search({'severity.severity' => + [make_list($param{severity})], }, {join => 'severity'}, ); } for my $key (qw(owner submitter done)) { if (exists $param{$key}) { - $rs = $rs->search({-or => {map {("${key}.addr" => $_)} - make_list($param{$key})}, + $rs = $rs->search({"${key}.addr" => + [make_list($param{$key})], }, {join => $key}, ); } } if (exists $param{correspondent}) { - $rs = $rs->search({-or => {map {('message_correspondents.addr' => $_)} - make_list($param{correspondent})}, + $rs = $rs->search({'message_correspondents.addr' => + [make_list($param{correspondent})], }, {join => {correspondent => {bug_messages => @@ -534,10 +535,11 @@ sub get_bugs_by_db{ ); } if (exists $param{affects}) { - $rs = $rs->search({-or => {map {('bin_pkg.pkg' => $_, - 'src_pkg.pkg' => $_, - )} - make_list($param{affects}), + my @aff_list = make_list($param{affects}); + $rs = $rs->search({-or => {'bin_pkg.pkg' => + [@aff_list], + 'src_pkg.pkg' => + [@aff_list], }, }, {join => [{bug_affects_binpackages => 'bin_pkg'}, @@ -547,17 +549,18 @@ sub get_bugs_by_db{ ); } if (exists $param{package}) { - $rs = $rs->search({-or => {map {('bin_pkg.pkg' => $_)} - make_list($param{package})}, + $rs = $rs->search({'bin_pkg.pkg' => + [make_list($param{package})], }, {join => {bug_binpackages => 'bin_pkg'}}); } if (exists $param{maintainer}) { - $rs = $rs->search({-or => {map {(correspondent => $_ eq '' ? undef : $_, - correspondent2 => $_ eq '' ? undef : $_, - )} - make_list($param{maintainer}) - } + my @maint_list = + map {$_ eq '' ? undef : $_} + make_list($param{maintainer}); + $rs = $rs->search({-or => {correspondent => [@maint_list], + correspondent2 => [@maint_list], + }, }, {join => {bug_affects_binpackage => {bin_pkg => @@ -618,7 +621,7 @@ searches. [Or at least, that's the idea.] =cut -my $_get_bugs_flatfile_options = +state $_get_bugs_flatfile_options = {hash_slice(%_get_bugs_common_options, map {$_ eq 'dist'?():($_)} keys %_get_bugs_common_options ) @@ -827,7 +830,7 @@ sub __handle_pkg_src_and_maint{ return grep {$packages{$_} >= $package_keys} keys %packages; } -my %field_match = ( +state $field_match = { 'subject' => \&__contains_field_match, 'tags' => sub { my ($field, $values, $status) = @_; @@ -843,14 +846,14 @@ my %field_match = ( 'originator' => \&__contains_field_match, 'forwarded' => \&__contains_field_match, 'owner' => \&__contains_field_match, -); +}; sub __bug_matches { my ($hash, $status) = @_; foreach my $key( keys( %$hash ) ) { my $value = $hash->{$key}; - next unless exists $field_match{$key}; - my $sub = $field_match{$key}; + next unless exists $field_match->{$key}; + my $sub = $field_match->{$key}; if (not defined $sub) { die "No defined subroutine for key: $key"; }