[prev] [thread] [next] [lurker] [Date index for 2003/04/12]
OK. Here is a patch to make mariachi use Email::Simple. I'm not convinced that it is correct. Also, I'm not convinced that it is faster. It seems to load much more quickly, but sort and particularly output generation are far slower, so it seems to be a net loss. I'm going to go to bed, and I'm not going to get a chance to look at this until at least Monday night. So anyone else is welcome to play. Also, I find that I want to apply this to Mail::Thread --- Thread.pm.orig Sat Apr 12 21:40:20 2003 +++ Thread.pm Sat Apr 12 22:15:18 2003 @@ -108,7 +108,7 @@ sub _setup { debug "\n\nLooking at ".$self->_msgid($message)."\n"; my $this_container = $self->_get_cont_for_id($self->_msgid($message)); $this_container->message($message); - debug " [".$this_container->subject."]\n----\n"; + debug " [",$this_container->subject,"]\n----\n"; my $prev = undef; my @refs = $self->_references($message); debug " Now looking at its references: @refs\n"; to stop lots of these warnings: Use of uninitialized value in concatenation (.) or string at /usr/local/lib/perl5/site_perl/5.9.0/Mail/Thread.pm line 111. I still have one of these: Use of uninitialized value in concatenation (.) or string at /usr/local/lib/perl5/site_perl/5.9.0/Email/Simple.pm line 208. That's here in sub _headers_as_string: $stuff .= _header_as_string($thing, $head{$thing}); The output appears to be identical, apart from the hashes generated for the filenames. Nick Index: mariachi =================================================================== --- mariachi (revision 703) +++ mariachi (working copy) @@ -8,10 +8,14 @@ my $maildir = shift || die "need an input maildir"; my $output = shift || die "where do we put them?"; -my @mails = map { - open my $fh, "<$_" or die "open: '$_' $!"; - Message->new($fh); -} <$maildir/cur/*>, <$maildir/new/*>; +my @mails + = do { + local $/; + map { + open my $fh, "<$_" or die "open: '$_' $!"; + Message->new(<$fh>); + } <$maildir/cur/*>, <$maildir/new/*>; + }; # some messages have been near mail2news gateways, which means that # some message ids get munged like so: <$group/$message_id> @@ -75,6 +79,11 @@ sub _container_class { "Mail::Thread::Container::Mariachi" } +sub _get_hdr { + my ($classs, $msg, $hdr) = @_; + $msg->header($hdr); +} + sub sorted_rootset { my $self = shift; _sort( $self->rootset ); @@ -136,10 +145,10 @@ } package Message; -use Mail::Internet; +use Email::Simple; use Digest::MD5 qw(md5_base64); -use base qw(Mail::Internet); +use base qw(Email::Simple); sub filename { my $self = shift; @@ -152,33 +161,31 @@ sub subject { my $self = shift; - my $subject = $self->head->get('subject'); + my $subject = $self->header('subject'); chomp $subject; $subject; } sub references { my $self = shift; - $self->head->replace('references', @_) if @_; - $self->head->get('references'); + @_ ? $self->header_set('references', @_) : $self->header('references'); } sub in_reply_to { my $self = shift; - $self->head->replace('in-reply-to', @_) if @_; - $self->head->get('in-reply-to'); + @_ ? $self->header_set('in-reply-to', @_) : $self->header('in-reply-to'); } sub date { my $self = shift; - my $date = $self->head->get('date'); + my $date = $self->header('date'); chomp $date; $date; } sub from { my $self = shift; - my $from = $self->head->get('from'); + my $from = $self->header('from'); $from =~ s/<.*>//; $from =~ s/\@\S+//; $from =~ s/\s+\z//;
Generated at 13:56 on 01 Jul 2004 by mariachi 0.52