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 4/6] searchidx: simplify quote-splitting in index_body
  2020-01-03  8:45  6% [PATCH 0/6] searchidx: minor fix and some cleanups Eric Wong
@ 2020-01-03  8:46  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-01-03  8:46 UTC (permalink / raw)
  To: meta

We now use the same regexp View::add_text_body uses.
---
 lib/PublicInbox/SearchIdx.pm | 28 ++++++++--------------------
 1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index 62e836e0..47537ed4 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -199,12 +199,12 @@ sub index_old_diff_fn {
 }
 
 sub index_diff ($$$) {
-	my ($self, $lines, $doc) = @_;
+	my ($self, $txt, $doc) = @_;
 	my %seen;
 	my $in_diff;
 	my @xnq;
 	my $xnq = \@xnq;
-	foreach (@$lines) {
+	foreach (split(/\n/, $txt)) {
 		if ($in_diff && s/^ //) { # diff context
 			index_diff_inc($self, $_, 'XDFCTX', $xnq);
 		} elsif (/^-- $/) { # email signature begins
@@ -278,20 +278,17 @@ sub index_diff ($$$) {
 }
 
 sub index_body ($$$) {
-	my ($self, $lines, $doc) = @_;
-	my $txt = join("\n", @$lines);
+	my ($self, $txt, $doc) = @_;
 	if ($doc) {
 		# does it look like a diff?
 		if ($txt =~ /^(?:diff|---|\+\+\+) /ms) {
-			$txt = undef;
-			index_diff($self, $lines, $doc);
+			index_diff($self, $txt, $doc);
 		} else {
 			index_text($self, $txt, 1, 'XNQ');
 		}
 	} else {
 		index_text($self, $txt, 0, 'XQUOT');
 	}
-	@$lines = ();
 }
 
 sub index_xapian { # msg_iter callback
@@ -306,19 +303,10 @@ sub index_xapian { # msg_iter callback
 	my ($s, undef) = msg_part_text($part, $ct);
 	defined $s or return;
 
-	my (@orig, @quot);
-	my @lines = split(/\n/, $s);
-	while (defined(my $l = shift @lines)) {
-		if ($l =~ /^>/) {
-			index_body($self, \@orig, $doc) if @orig;
-			push @quot, $l;
-		} else {
-			index_body($self, \@quot, 0) if @quot;
-			push @orig, $l;
-		}
-	}
-	index_body($self, \@quot, 0) if @quot;
-	index_body($self, \@orig, $doc) if @orig;
+	# split off quoted and unquoted blocks:
+	my @sections = split(/((?:^>[^\n]*\n)+)/sm, $s);
+	$part = $s = undef;
+	index_body($self, $_, /\A>/ ? 0 : $doc) for @sections;
 }
 
 sub add_xapian ($$$$$$) {

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/6] searchidx: minor fix and some cleanups
@ 2020-01-03  8:45  6% Eric Wong
  2020-01-03  8:46  7% ` [PATCH 4/6] searchidx: simplify quote-splitting in index_body Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2020-01-03  8:45 UTC (permalink / raw)
  To: meta

1/6 is a real bug fix, 4/6 is a nice simplification
and the rest makes reading easier when I haven't looked
at the indexing code in a while.

Xapian indexing is still expensive, though...

Eric Wong (6):
  searchidx: index_diff: allow /^$/ line as diff context
  searchidx: split off index_xapian for msg_iter
  searchidx: add_message: fix and make use of prototypes
  searchidx: simplify quote-splitting in index_body
  searchidx: index_text: use Xapian parameter names
  searchidx: remove_message: pedantic fix for v1

 lib/PublicInbox/SearchIdx.pm | 177 ++++++++++++++++-------------------
 1 file changed, 83 insertions(+), 94 deletions(-)


^ permalink raw reply	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-01-03  8:45  6% [PATCH 0/6] searchidx: minor fix and some cleanups Eric Wong
2020-01-03  8:46  7% ` [PATCH 4/6] searchidx: simplify quote-splitting in index_body 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).