From 271477d8c26794abd8310e2abb89b746204660af Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Thu, 22 Apr 2010 11:02:17 -0700 Subject: Bug 560009: Use firstidx from List::MoreUtils instead of lsearch r=timello, a=mkanat --- Bugzilla/Migrate/Gnats.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'Bugzilla/Migrate/Gnats.pm') diff --git a/Bugzilla/Migrate/Gnats.pm b/Bugzilla/Migrate/Gnats.pm index 232100f2d..ff24f73b5 100644 --- a/Bugzilla/Migrate/Gnats.pm +++ b/Bugzilla/Migrate/Gnats.pm @@ -25,12 +25,13 @@ use base qw(Bugzilla::Migrate); use Bugzilla::Constants; use Bugzilla::Install::Util qw(indicate_progress); -use Bugzilla::Util qw(format_time trim generate_random_password lsearch); +use Bugzilla::Util qw(format_time trim generate_random_password); use Email::Address; use Email::MIME; use File::Basename; use IO::File; +use List::MoreUtils qw(firstidx); use List::Util qw(first); use constant REQUIRED_MODULES => [ @@ -168,14 +169,14 @@ use constant NON_COMMENT_FIELDS => qw( # we list out here the exact order of fields at the end of a PR # and wait for the next field to consider that we actually have # a field to parse. -use constant END_FIELD_ORDER => [qw( +use constant END_FIELD_ORDER => qw( Description How-To-Repeat Fix Release-Note Audit-Trail Unformatted -)]; +); use constant CUSTOM_FIELDS => { cf_type => { @@ -374,10 +375,12 @@ sub _get_gnats_field_data { # If this is one of the last few PR fields, then make sure # that we're getting our fields in the right order. my $new_field_valid = 1; - my $current_field_pos = - lsearch(END_FIELD_ORDER, $current_field || ''); + my $search_for = $current_field || ''; + my $current_field_pos = firstidx { $_ eq $search_for } + END_FIELD_ORDER; if ($current_field_pos > -1) { - my $new_field_pos = lsearch(END_FIELD_ORDER, $new_field); + my $new_field_pos = firstidx { $_ eq $new_field } + END_FIELD_ORDER; # We accept any field, as long as it's later than this one. $new_field_valid = $new_field_pos > $current_field_pos ? 1 : 0; } -- cgit v1.2.3-24-g4f1b