user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 06/11] search: avoid needless decode
  @ 2015-08-20  2:57  7% ` Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2015-08-20  2:57 UTC (permalink / raw)
  To: meta

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.
---
 lib/PublicInbox/Search.pm | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index c28401b..aa29ae5 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;
 			}
 		});
-- 
EW


^ permalink raw reply related	[relevance 7%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-08-20  2:57     [PATCH 01/11] feed: remove threading from index Eric Wong
2015-08-20  2:57  7% ` [PATCH 06/11] search: avoid needless decode Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).