Subject: | Significant performance improvement for message parsing |
I was able to extract a significant 15+% improvement in message parsing by a simple modification to Mail/Box/Parser/Perl.pm where it searches for boundary lines. The only change is to remove $file->getpos() out of the most common loop for MIME email around line 180
LINE: while(1)
{ my $line = $file->getline or last;
foreach my $sep (@seps)
{ next if substr($line, 0, length $sep) ne $sep;
next if $sep eq 'From ' && $line !~ m/ (?:19[789]\d|20[01]\d)/;
$file->setpos($file->getpos - length $line);
last LINE;
}
$line =~ s/\015$//;
push @$lines, $line;
}
}