Commit 49449152 authored by mkanat%bugzilla.org's avatar mkanat%bugzilla.org

Bug 342749: Replace Bugzilla::Util's min and max with the List::Util equivalents

Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=colin.ogilvie, r=vladd, a=justdave
parent cb1a7709
...@@ -43,6 +43,8 @@ use Bugzilla::Util; ...@@ -43,6 +43,8 @@ use Bugzilla::Util;
use Bugzilla::Error; use Bugzilla::Error;
use Bugzilla::Product; use Bugzilla::Product;
use List::Util qw(min);
use base qw(Exporter); use base qw(Exporter);
@Bugzilla::Bug::EXPORT = qw( @Bugzilla::Bug::EXPORT = qw(
AppendComment ValidateComment AppendComment ValidateComment
......
...@@ -38,6 +38,7 @@ use Bugzilla::Series; ...@@ -38,6 +38,7 @@ use Bugzilla::Series;
use Date::Format; use Date::Format;
use Date::Parse; use Date::Parse;
use List::Util qw(max);
sub new { sub new {
my $invocant = shift; my $invocant = shift;
...@@ -313,10 +314,10 @@ sub readData { ...@@ -313,10 +314,10 @@ sub readData {
my $datediff = shift @datediff_total; my $datediff = shift @datediff_total;
push @processed_datediff, $datediff if defined($datediff); push @processed_datediff, $datediff if defined($datediff);
} }
$self->{'y_max_value'} = Bugzilla::Util::max(@processed_datediff); $self->{'y_max_value'} = max(@processed_datediff);
} }
else { else {
$self->{'y_max_value'} = Bugzilla::Util::max(@maxvals); $self->{'y_max_value'} = max(@maxvals);
} }
$self->{'y_max_value'} |= 1; # For log() $self->{'y_max_value'} |= 1; # For log()
......
...@@ -35,7 +35,7 @@ use base qw(Exporter); ...@@ -35,7 +35,7 @@ use base qw(Exporter);
html_quote url_quote value_quote xml_quote html_quote url_quote value_quote xml_quote
css_class_quote css_class_quote
i_am_cgi get_netaddr i_am_cgi get_netaddr
lsearch max min lsearch
diff_arrays diff_strings diff_arrays diff_strings
trim wrap_comment find_wrap_point trim wrap_comment find_wrap_point
perform_substs perform_substs
...@@ -158,22 +158,6 @@ sub lsearch { ...@@ -158,22 +158,6 @@ sub lsearch {
return -1; return -1;
} }
sub max {
my $max = shift(@_);
foreach my $val (@_) {
$max = $val if $val > $max;
}
return $max;
}
sub min {
my $min = shift(@_);
foreach my $val (@_) {
$min = $val if $val < $min;
}
return $min;
}
sub diff_arrays { sub diff_arrays {
my ($old_ref, $new_ref) = @_; my ($old_ref, $new_ref) = @_;
...@@ -450,8 +434,6 @@ Bugzilla::Util - Generic utility functions for bugzilla ...@@ -450,8 +434,6 @@ Bugzilla::Util - Generic utility functions for bugzilla
# Functions for searching # Functions for searching
$loc = lsearch(\@arr, $val); $loc = lsearch(\@arr, $val);
$val = max($a, $b, $c);
$val = min($a, $b, $c);
# Data manipulation # Data manipulation
($removed, $added) = diff_arrays(\@old, \@new); ($removed, $added) = diff_arrays(\@old, \@new);
...@@ -598,14 +580,6 @@ reference. ...@@ -598,14 +580,6 @@ reference.
If the item is not in the list, returns -1. If the item is not in the list, returns -1.
=item C<max($a, $b, ...)>
Returns the maximum from a set of values.
=item C<min($a, $b, ...)>
Returns the minimum from a set of values.
=back =back
=head2 Data Manipulation =head2 Data Manipulation
......
...@@ -28,7 +28,7 @@ use lib 't'; ...@@ -28,7 +28,7 @@ use lib 't';
use Support::Files; use Support::Files;
BEGIN { BEGIN {
use Test::More tests => 15; use Test::More tests => 13;
use_ok(Bugzilla); use_ok(Bugzilla);
use_ok(Bugzilla::Util); use_ok(Bugzilla::Util);
} }
...@@ -57,11 +57,6 @@ is(lsearch(\@list,'pear'),1,'lsearch 1'); ...@@ -57,11 +57,6 @@ is(lsearch(\@list,'pear'),1,'lsearch 1');
is(lsearch(\@list,'<"\\%'),3,'lsearch 2'); is(lsearch(\@list,'<"\\%'),3,'lsearch 2');
is(lsearch(\@list,'kiwi'),-1,'lsearch 3 (missing item)'); is(lsearch(\@list,'kiwi'),-1,'lsearch 3 (missing item)');
#max() and min():
@list = (7,27,636,2);
is(max(@list),636,'max()');
is(min(@list),2,'min()');
#trim(): #trim():
is(trim(" fg<*\$%>+=~~ "),'fg<*$%>+=~~','trim()'); is(trim(" fg<*\$%>+=~~ "),'fg<*$%>+=~~','trim()');
......
...@@ -36,6 +36,8 @@ use Bugzilla::Bug; ...@@ -36,6 +36,8 @@ use Bugzilla::Bug;
use Bugzilla::User; use Bugzilla::User;
use Bugzilla::Product; use Bugzilla::Product;
use List::Util qw(min);
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template; my $template = Bugzilla->template;
my $vars = {}; my $vars = {};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment