Explorar el Código

* Applied patch by Hanno Hecker to keep only the last 50 quotes for each
nick while parsing. Saves memory and is probably saner anyway (thanks!).

Christoph Berg hace 21 años
padre
commit
3923902078
Se han modificado 3 ficheros con 17 adiciones y 4 borrados
  1. 1 1
      docs/CREDITS
  2. 2 0
      docs/Changelog
  3. 14 3
      modules/Pisg/Parser/Logfile.pm

+ 1 - 1
docs/CREDITS

@@ -54,7 +54,7 @@ Other contributors:
    | Compressed files, addition of --prefix, and sorting of files in logdirs
    | Compressed files, addition of --prefix, and sorting of files in logdirs
  * JaMiR0W <jamirow@ig.com.br>
  * JaMiR0W <jamirow@ig.com.br>
    | Portugese translation
    | Portugese translation
- * Hanno Hecker (Vetinari) <hanno-pisg@bee.de>
+ * Hanno Hecker (Vetinari) <vetinari@ankh-morp.org>
    | Lots of feature additions and code cleanups, thanks!
    | Lots of feature additions and code cleanups, thanks!
    | Updates to German translation, some patches for words and the feature
    | Updates to German translation, some patches for words and the feature
      'most words'.
      'most words'.

+ 2 - 0
docs/Changelog

@@ -15,6 +15,8 @@ pisg (0.64) - ??
      LogDirs.
      LogDirs.
    * No "Userpic" headline was shown when there were only DefaultPics.
    * No "Userpic" headline was shown when there were only DefaultPics.
    * Make "most used words" case-insensitive.
    * Make "most used words" case-insensitive.
+   * Applied patch by Hanno Hecker to keep only the last 50 quotes for each
+     nick while parsing. Saves memory and is probably saner anyway (thanks!).
 
 
 pisg (0.63) - Wed Jan, 12th 2005
 pisg (0.63) - Wed Jan, 12th 2005
    Morten:
    Morten:

+ 14 - 3
modules/Pisg/Parser/Logfile.pm

@@ -405,7 +405,7 @@ sub _parse_file
             }
             }
             $lastnormal = $line;
             $lastnormal = $line;
             $repeated = 0;
             $repeated = 0;
-        }
+        } # normal lines
 
 
         # Match action lines.
         # Match action lines.
         elsif ($hashref = $self->{parser}->actionline($line, $.)) {
         elsif ($hashref = $self->{parser}->actionline($line, $.)) {
@@ -468,7 +468,7 @@ sub _parse_file
 
 
                 _parse_words($stats, $saying, $nick, $self->{ignorewords_regexp}, $hour);
                 _parse_words($stats, $saying, $nick, $self->{ignorewords_regexp}, $hour);
             }
             }
-        }
+        } # action lines
 
 
         # Match *** lines.
         # Match *** lines.
         elsif (($hashref = $self->{parser}->thirdline($line, $.)) and $hashref->{nick}) {
         elsif (($hashref = $self->{parser}->thirdline($line, $.)) and $hashref->{nick}) {
@@ -530,8 +530,19 @@ sub _parse_file
                     checkname($nick, $newnick, $stats) if ($self->{cfg}->{showmostnicks});
                     checkname($nick, $newnick, $stats) if ($self->{cfg}->{showmostnicks});
                 }
                 }
             }
             }
+        } # *** lines
+
+        unless ($stats->{parsedlines} % 10000) { # keep only recent quotes to same mem
+            foreach my $n (keys %{$lines->{sayings}}) {
+                my $x = @{$lines->{sayings}->{$n}};
+                splice(@{$lines->{sayings}->{$n}}, 0, ($x - 50)) if ($x > 75);
+            }
+            foreach my $n (keys %{$lines->{actionlines}}) {
+                my $y = @{$lines->{actionlines}->{$n}};
+                splice(@{$lines->{actionlines}->{$n}}, 0, ($y - 50)) if ($y > 75);
+            }
         }
         }
-    }
+    } # while(my $line = <LOGFILE>)
 
 
     $stats->{totallines} = $.;
     $stats->{totallines} = $.;