You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by fe...@apache.org on 2006/10/19 21:42:22 UTC
svn commit: r465748 -
/spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm
Author: felicity
Date: Thu Oct 19 12:42:22 2006
New Revision: 465748
URL: http://svn.apache.org/viewvc?view=rev&rev=465748
Log:
bug 5141: reduce the memory usage during 'mass-check -n' by reusing an array reference instead of copying all the data around
Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm?view=diff&rev=465748&r1=465747&r2=465748
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm Thu Oct 19 12:42:22 2006
@@ -488,7 +488,7 @@
}
}
- my @messages;
+ my $messages;
if ($self->{opt_n}) {
# OPT_N == 1 means don't bother sorting on message receive date
@@ -502,8 +502,10 @@
splice(@{$self->{h}}, min ($self->{opt_head}, scalar @{$self->{h}}));
}
- @messages = ( @{$self->{s}}, @{$self->{h}} );
+ # for ease of memory, we'll play with pointers
+ $messages = $self->{s};
undef $self->{s};
+ push(@{$messages}, @{$self->{h}});
undef $self->{h};
}
else {
@@ -529,22 +531,22 @@
if (@s && @h) {
my $ratio = @s / @h;
while (@s && @h) {
- push @messages, (@s / @h > $ratio) ? (shift @s) : (shift @h);
+ push @{$messages}, (@s / @h > $ratio) ? (shift @s) : (shift @h);
}
}
# push the rest onto the end
- push @messages, @s, @h;
+ push @{$messages}, @s, @h;
}
# head or tail < 0 means crop the total list, negate the value appropriately
if ($self->{opt_tail} < 0) {
- splice(@messages, 0, $self->{opt_tail});
+ splice(@{$messages}, 0, $self->{opt_tail});
}
if ($self->{opt_head} < 0) {
- splice(@messages, -$self->{opt_head});
+ splice(@{$messages}, -$self->{opt_head});
}
- return scalar(@messages), \@messages;
+ return scalar(@{$messages}), $messages;
}
sub mail_open {