Просмотр исходного кода

* Clean up loop code in _mostnicks() and fix warning about calls to is_ignored(undef).

Christoph Berg 22 лет назад
Родитель
Сommit
1aab40beff
2 измененных файлов с 14 добавлено и 8 удалено
  1. 5 0
      docs/Changelog
  2. 9 8
      modules/Pisg/HTMLGenerator.pm

+ 5 - 0
docs/Changelog

@@ -1,3 +1,8 @@
+pisg (0.60) - ??
+   Changes by Christoph Berg:
+   * Clean up loop code in _mostnicks() and fix warning about calls to
+   is_ignored(undef).
+
 pisg (0.59) - Sun Oct, 3rd 2004
    Changes by Morten Brix Pedersen:
    * Fix problem with number of rows shown when a nick has been ignored.

+ 9 - 8
modules/Pisg/HTMLGenerator.pm

@@ -1993,13 +1993,13 @@ sub _mostnicks
         _html("<td>&nbsp;</td><td class=\"tdtop\"><b>$nick_txt</b></td>");
         _html("<td class=\"tdtop\"><b>$names_txt</b></td></tr>");
 
-        for(my $i = 0, my $a = 0; $a < $self->{cfg}->{mostnickshistory}; $i++) {
-            next if is_ignored($sortnicks[$i]);
-            last unless $i < @sortnicks;
-            my $nickcount = keys %{ $self->{stats}->{nicks}->{$sortnicks[$i]} };
-            my $nickused = join(", ", values %{ $self->{stats}->{nicks}->{$sortnicks[$i]} });
+        my $a = 0;
+        foreach my $nick (@sortnicks) {
+            next if is_ignored($nick);
+            my $nickcount = keys %{ $self->{stats}->{nicks}->{$nick} };
+            my $nickused = join(", ", values %{ $self->{stats}->{nicks}->{$nick} });
 
-            next unless ($nickcount > 1);
+            last unless ($nickcount > 1);
 
             $a++;
             my $class = $a == 1 ? 'hirankc' : 'rankc';
@@ -2007,13 +2007,14 @@ sub _mostnicks
 
             _html("<tr><td class=\"$class\">$a</td>");
             if ($self->{cfg}->{mostnicksverbose}) { 
-                _html("<td class=\"hicell\">$sortnicks[$i] ($nickcount $n)</td>");
+                _html("<td class=\"hicell\">$nick ($nickcount $n)</td>");
                 _html("<td class=\"hicell\" valign='top'>$nickused</td>");
             } else {
-                _html("<td class=\"hicell\">$sortnicks[$i]</td>");
+                _html("<td class=\"hicell\">$nick</td>");
                 _html("<td class=\"hicell\" valign='top'>$nickcount $n</td>");
             }
             _html("</tr>");
+            last if $a >= $self->{cfg}->{mostnickshistory};
         }
         _html("</table>");
     }