diff options
author | Eric Wong <e@80x24.org> | 2015-08-20 02:30:30 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-08-20 02:31:37 +0000 |
commit | 89a2237b49cac7690582c5ada1ed3466d0f57944 (patch) | |
tree | 5c9a8652d962cd0e86995f11ffe37b819e78c158 /lib | |
parent | d0fb726671b98771b982000d408db14ad492c5e1 (diff) | |
download | public-inbox-89a2237b49cac7690582c5ada1ed3466d0f57944.tar.gz |
Email::MIME should handle everything for us and make things work nicely with Xapian (assuming I understand how encoding works in Perl). While we're at it, reduce temporary strings and arrays by using destructive operations and clobbering parts as we iterate through them.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/Search.pm | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index c28401bc..aa29ae53 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -6,7 +6,6 @@ use strict; use warnings; use PublicInbox::SearchMsg; use Search::Xapian qw/:standard/; -require PublicInbox::View; use Email::MIME; use PublicInbox::MID qw/mid_clean mid_compressed/; @@ -88,7 +87,6 @@ sub add_message { my $mid = mid_compressed($mid_orig); my $was_ghost = 0; my $ct_msg = $mime->header('Content-Type') || 'text/plain'; - my $enc_msg = PublicInbox::View::enc_for($ct_msg); eval { my $smsg = $self->lookup_message($mid); @@ -151,9 +149,11 @@ sub add_message { # account for filter bugs... $ct =~ m!\btext/plain\b!i or return; - my $enc = PublicInbox::View::enc_for($ct, $enc_msg); my (@orig, @quot); - foreach my $l (split(/\n/, $enc->decode($part->body))) { + my $body = $part->body; + $part->body_set(''); + my @lines = split(/\n/, $body); + while (defined(my $l = shift @lines)) { if ($l =~ /^\s*>/) { push @quot, $l; } else { @@ -162,10 +162,12 @@ sub add_message { } if (@quot) { $tg->index_text(join("\n", @quot), 0); + @quot = (); $tg->increase_termpos; } if (@orig) { $tg->index_text(join("\n", @orig)); + @orig = (); $tg->increase_termpos; } }); |