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 5/8] view,searchview: avoid smsg method calls when using SQLite/Xapian
  2020-02-15  9:46  6% [PATCH 0/8] some view cleanups and minor bugfixes Eric Wong
@ 2020-02-15  9:46  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-02-15  9:46 UTC (permalink / raw)
  To: meta

We already pre-populate the hashref when loading $smsg
(PublicInbox::SearchMsg) objects out of over.sqlite3 or Xapian,
so making expensive method calls isn't necessary in those cases.

We only need to use the method calls when SQLite or Xapian are
not available or are being populated (such as during indexing).
---
 lib/PublicInbox/SearchView.pm |  8 ++++----
 lib/PublicInbox/View.pm       | 16 ++++++++--------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm
index 828926c7..7e508bb7 100644
--- a/lib/PublicInbox/SearchView.pm
+++ b/lib/PublicInbox/SearchView.pm
@@ -108,14 +108,14 @@ sub mset_summary {
 			};
 			next;
 		}
-		my $s = ascii_html($smsg->subject);
-		my $f = ascii_html($smsg->from_name);
+		my $s = ascii_html($smsg->{subject});
+		my $f = ascii_html($smsg->{from_name});
 		if ($obfs_ibx) {
 			obfuscate_addrs($obfs_ibx, $s);
 			obfuscate_addrs($obfs_ibx, $f);
 		}
-		my $date = PublicInbox::View::fmt_ts($smsg->ds);
-		my $mid = PublicInbox::Hval->new_msgid($smsg->mid)->{href};
+		my $date = PublicInbox::View::fmt_ts($smsg->{ds});
+		my $mid = PublicInbox::Hval->new_msgid($smsg->{mid})->{href};
 		$s = '(no subject)' if $s eq '';
 		$$res .= qq{$rank. <b><a\nhref="$mid/">}.
 			$s . "</a></b>\n";
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index e586b068..033a0c14 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -84,7 +84,7 @@ sub msg_page_more {
 	my $next = $ibx->over->next_by_mid($ctx->{mid}, \$id, \$prev);
 	$ctx->{more} = $next ? [ $id, $prev, $next ] : undef;
 	return '' unless $smsg;
-	$ctx->{mhref} = '../' . mid_escape($smsg->mid) . '/';
+	$ctx->{mhref} = '../' . mid_escape($smsg->{mid}) . '/';
 	my $mime = delete $smsg->{mime};
 	_msg_page_prepare_obuf($mime->header_obj, $ctx, $nr);
 	multipart_text_as_html($mime, $ctx);
@@ -423,7 +423,7 @@ sub stream_thread ($$) {
 	return missing_thread($ctx) unless $smsg;
 
 	$ctx->{-obfs_ibx} = $ibx->{obfuscate} ? $ibx : undef;
-	$ctx->{-title_html} = ascii_html($smsg->subject);
+	$ctx->{-title_html} = ascii_html($smsg->{subject});
 	$ctx->{-html_tip} = thread_index_entry($ctx, $level, $smsg);
 	$ctx->{-queue} = \@q;
 	PublicInbox::WwwStream->response($ctx, 200, \&stream_thread_i);
@@ -469,7 +469,7 @@ sub thread_html {
 		$smsg = $ibx->smsg_mime($m) and last;
 	}
 	return missing_thread($ctx) unless $smsg;
-	$ctx->{-title_html} = ascii_html($smsg->subject);
+	$ctx->{-title_html} = ascii_html($smsg->{subject});
 	$ctx->{-html_tip} = '<pre>'.index_entry($smsg, $ctx, scalar @$msgs);
 	$ctx->{msgs} = $msgs;
 	PublicInbox::WwwStream->response($ctx, 200, \&thread_html_i);
@@ -932,7 +932,7 @@ sub skel_dump { # walk_thread callback
 		$$skel .= delete($ctx->{sl_note}) || '';
 	}
 
-	my $f = ascii_html($smsg->from_name);
+	my $f = ascii_html($smsg->{from_name});
 	my $obfs_ibx = $ctx->{-obfs_ibx};
 	obfuscate_addrs($obfs_ibx, $f) if $obfs_ibx;
 
@@ -971,7 +971,7 @@ sub skel_dump { # walk_thread callback
 	# Subject is never undef, this mail was loaded from
 	# our Xapian which would've resulted in '' if it were
 	# really missing (and Filter rejects empty subjects)
-	my @subj = split(/ /, subject_normalized($smsg->subject));
+	my @subj = split(/ /, subject_normalized($smsg->{subject}));
 	# remove common suffixes from the subject if it matches the previous,
 	# so we do not show redundant text at the end.
 	my $prev_subj = $ctx->{prev_subj} || [];
@@ -1029,8 +1029,8 @@ sub _skel_ghost {
 
 sub sort_ds {
 	[ sort {
-		(eval { $a->topmost->{smsg}->ds } || 0) <=>
-		(eval { $b->topmost->{smsg}->ds } || 0)
+		(eval { $a->topmost->{smsg}->{ds} } || 0) <=>
+		(eval { $b->topmost->{smsg}->{ds} } || 0)
 	} @{$_[0]} ];
 }
 
@@ -1041,7 +1041,7 @@ sub acc_topic { # walk_thread callback
 	my $mid = $node->{id};
 	my $smsg = $node->{smsg} // $ctx->{-inbox}->smsg_by_mid($mid);
 	if ($smsg) {
-		my $subj = subject_normalized($smsg->subject);
+		my $subj = subject_normalized($smsg->{subject});
 		$subj = '(no subject)' if $subj eq '';
 		my $ds = $smsg->{ds};
 		if ($level == 0) { # new, top-level topic

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/8] some view cleanups and minor bugfixes
@ 2020-02-15  9:46  6% Eric Wong
  2020-02-15  9:46  7% ` [PATCH 5/8] view,searchview: avoid smsg method calls when using SQLite/Xapian Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2020-02-15  9:46 UTC (permalink / raw)
  To: meta

Pretty insignificant, but the diffstat makes me happy :>

Eric Wong (8):
  view: remove mhref arg from multipart_text_as_html
  view: single id="t" for multi-Subject messages
  view: dump_topics: better naming of top Subject
  view: cleanup topic accumulation and dumping
  view,searchview: avoid smsg method calls when using SQLite/Xapian
  view: escape Subject HTML directly
  view: escape ampersand in Message-IDs
  view: remove last Hval->new caller

 lib/PublicInbox/ExtMsg.pm        |  19 ++--
 lib/PublicInbox/Hval.pm          |  28 +-----
 lib/PublicInbox/Linkify.pm       |   9 +-
 lib/PublicInbox/Reply.pm         |   6 +-
 lib/PublicInbox/SearchView.pm    |  10 +--
 lib/PublicInbox/View.pm          | 144 ++++++++++++++-----------------
 lib/PublicInbox/WwwAtomStream.pm |  12 +--
 t/psgi_bad_mids.t                |   9 +-
 xt/perf-msgview.t                |   3 +-
 9 files changed, 104 insertions(+), 136 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-02-15  9:46  6% [PATCH 0/8] some view cleanups and minor bugfixes Eric Wong
2020-02-15  9:46  7% ` [PATCH 5/8] view,searchview: avoid smsg method calls when using SQLite/Xapian 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).