]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 342749: Replace Bugzilla::Util's min and max with the List::Util equivalents
authormkanat%bugzilla.org <>
Tue, 27 Jun 2006 17:54:04 +0000 (17:54 +0000)
committermkanat%bugzilla.org <>
Tue, 27 Jun 2006 17:54:04 +0000 (17:54 +0000)
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=colin.ogilvie, r=vladd, a=justdave

Bugzilla/Bug.pm
Bugzilla/Chart.pm
Bugzilla/Util.pm
t/007util.t
votes.cgi

index 8be6705efd7e07443fa50e64a6593e88a409fa5d..8b6302b92c228eb2c35a85cfa845dfb2e25a6cf1 100755 (executable)
@@ -43,6 +43,8 @@ use Bugzilla::Util;
 use Bugzilla::Error;
 use Bugzilla::Product;
 
+use List::Util qw(min);
+
 use base qw(Exporter);
 @Bugzilla::Bug::EXPORT = qw(
     AppendComment ValidateComment
index b2db9da3005c6b033b80cc24604ae70f03e52733..729120e8e9c6c460ffe46f74314f44d37fb3d371 100644 (file)
@@ -38,6 +38,7 @@ use Bugzilla::Series;
 
 use Date::Format;
 use Date::Parse;
+use List::Util qw(max);
 
 sub new {
     my $invocant = shift;
@@ -313,10 +314,10 @@ sub readData {
             my $datediff = shift @datediff_total;
             push @processed_datediff, $datediff if defined($datediff);
         }
-        $self->{'y_max_value'} = Bugzilla::Util::max(@processed_datediff);
+        $self->{'y_max_value'} = max(@processed_datediff);
     }
     else {
-        $self->{'y_max_value'} = Bugzilla::Util::max(@maxvals);
+        $self->{'y_max_value'} = max(@maxvals);
     }
     $self->{'y_max_value'} |= 1; # For log()
 
index 6660fff91a17d905d9531f9c4ad7687db994d0f5..c5cfc0444282469a377ed6ff08a4b707c3703d87 100644 (file)
@@ -35,7 +35,7 @@ use base qw(Exporter);
                              html_quote url_quote value_quote xml_quote
                              css_class_quote
                              i_am_cgi get_netaddr
-                             lsearch max min
+                             lsearch
                              diff_arrays diff_strings
                              trim wrap_comment find_wrap_point
                              perform_substs
@@ -158,22 +158,6 @@ sub lsearch {
     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 {
     my ($old_ref, $new_ref) = @_;
 
@@ -450,8 +434,6 @@ Bugzilla::Util - Generic utility functions for bugzilla
 
   # Functions for searching
   $loc = lsearch(\@arr, $val);
-  $val = max($a, $b, $c);
-  $val = min($a, $b, $c);
 
   # Data manipulation
   ($removed, $added) = diff_arrays(\@old, \@new);
@@ -598,14 +580,6 @@ reference.
 
 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
 
 =head2 Data Manipulation
index 3adbe0ab44a4b94a79613740a6745d4b92a80c9f..5f2c998d1675850e743d85846bd5eed00d56718f 100644 (file)
@@ -28,7 +28,7 @@ use lib 't';
 use Support::Files;
 
 BEGIN { 
-        use Test::More tests => 15;
+        use Test::More tests => 13;
         use_ok(Bugzilla);
         use_ok(Bugzilla::Util);
 }
@@ -57,11 +57,6 @@ is(lsearch(\@list,'pear'),1,'lsearch 1');
 is(lsearch(\@list,'<"\\%'),3,'lsearch 2');
 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():
 is(trim(" fg<*\$%>+=~~ "),'fg<*$%>+=~~','trim()');
 
index 36661c278a742324688aa823e0483e1f325558a8..bb2948b3784980c2af2751c57baf922af5c5247a 100755 (executable)
--- a/votes.cgi
+++ b/votes.cgi
@@ -36,6 +36,8 @@ use Bugzilla::Bug;
 use Bugzilla::User;
 use Bugzilla::Product;
 
+use List::Util qw(min);
+
 my $cgi = Bugzilla->cgi;
 my $template = Bugzilla->template;
 my $vars = {};