You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by qu...@apache.org on 2004/11/22 04:40:41 UTC

svn commit: r106149 - /spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm

Author: quinlan
Date: Sun Nov 21 19:40:40 2004
New Revision: 106149

Modified:
   spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm
Log:
interleave spam and ham as evenly as possible


Modified: spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm
Url: http://svn.apache.org/viewcvs/spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm?view=diff&rev=106149&p1=spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm&r1=106148&p2=spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm&r2=106149
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm	(original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm	Sun Nov 21 19:40:40 2004
@@ -748,25 +748,12 @@
     }
 
     # interleave ordered spam and ham
-    if (@h && @s > @h) {
-      my $num = int(scalar(@s)/scalar(@h));
-      while(@s && @h) {
-        push @messages, (splice @s, 0, $num), (splice @h, 0, 1);
+    if (@s && @h) {
+      my $ratio = @s / @h;
+      while (@s && @h) {
+	push @messages, (@s / @h > $ratio) ? (shift @s) : (shift @h);
       }
     }
-    elsif (@s && @h > @s) {
-      my $num = int(scalar(@h)/scalar(@s));
-      while(@s && @h) {
-        push @messages, (splice @s, 0, 1), (splice @h, 0, $num);
-      }
-    }
-    else {
-      # This is infrequent unless --head or --tail is used ...
-      while(@s && @h) {
-        push @messages, (shift @s), (shift @h);
-      }
-    }
-
     # push the rest onto the end
     push @messages, @s, @h;
   }

Re: svn commit: r106149 - /spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm

Posted by Theo Van Dinter <fe...@kluge.net>.
On Sun, Nov 21, 2004 at 10:53:34PM -0800, Dan Quinlan wrote:
> In Soviet Russia, code vetos you.

Heh.  Thank you Yakov.

Actually, since that section of code is surrounded by "if (@s && @h) {", @h is
guaranteed to be >=1.  So I revoke my -1. :)

-- 
Randomly Generated Tagline:
"Do not meddle in the affairs of wizards,
 for they are subtle and quick to anger."    - Lord of the Rings

Re: svn commit: r106149 - /spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm

Posted by Daniel Quinlan <qu...@pathname.com>.
Theo Van Dinter <fe...@kluge.net> writes:

> -1
> 
> this doesn't take into account when @h == 0.  it'd be easy to do a
> ternary for $ratio to solve this.

In Soviet Russia, code vetos you.

-- 
Daniel Quinlan
http://www.pathname.com/~quinlan/

Re: svn commit: r106149 - /spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm

Posted by Theo Van Dinter <fe...@kluge.net>.
On Mon, Nov 22, 2004 at 03:40:41AM -0000, quinlan@apache.org wrote:
> +    if (@s && @h) {
> +      my $ratio = @s / @h;
> +      while (@s && @h) {
> +	push @messages, (@s / @h > $ratio) ? (shift @s) : (shift @h);

-1

this doesn't take into account when @h == 0.  it'd be easy to do a ternary for
$ratio to solve this.

-- 
Randomly Generated Tagline:
"Besides, I think [Slackware] sounds better than 'Microsoft,' don't you?"
 (By Patrick Volkerding)