From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] view: avoid deduping a single word in subject skeletons
Date: Thu, 21 Dec 2017 01:00:12 +0000 [thread overview]
Message-ID: <20171221010012.23680-1-e@80x24.org> (raw)
It is usually pointless to replace a single word with a '"' character.
---
lib/PublicInbox/View.pm | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 41f1321..81e83d9 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -755,6 +755,25 @@ sub _msg_date {
sub fmt_ts { POSIX::strftime('%Y-%m-%d %k:%M', gmtime($_[0])) }
+sub dedupe_subject {
+ my ($prev_subj, $subj, $val) = @_;
+
+ my $omit = ''; # '"' denotes identical text omitted
+ my (@prev_pop, @curr_pop);
+ while (@$prev_subj && @$subj && $subj->[-1] eq $prev_subj->[-1]) {
+ push(@prev_pop, pop(@$prev_subj));
+ push(@curr_pop, pop(@$subj));
+ $omit ||= $val;
+ }
+ pop @$subj if @$subj && $subj->[-1] =~ /^re:\s*/i;
+ if (scalar(@curr_pop) == 1) {
+ $omit = '';
+ push @$prev_subj, @prev_pop;
+ push @$subj, @curr_pop;
+ }
+ $omit;
+}
+
sub skel_dump {
my ($ctx, $level, $node) = @_;
my $smsg = $node->{smsg} or return _skel_ghost($ctx, $level, $node);
@@ -798,13 +817,7 @@ sub skel_dump {
# so we do not show redundant text at the end.
my $prev_subj = $ctx->{prev_subj} || [];
$ctx->{prev_subj} = [ @subj ];
- my $omit = ''; # '"' denotes identical text omitted
- while (@$prev_subj && @subj && $subj[-1] eq $prev_subj->[-1]) {
- pop @$prev_subj;
- pop @subj;
- $omit ||= '" ';
- }
- pop @subj if @subj && $subj[-1] =~ /^re:\s*/i;
+ my $omit = dedupe_subject($prev_subj, \@subj, '" ');
my $end;
if (@subj) {
my $subj = join(' ', @subj);
@@ -944,14 +957,7 @@ sub dump_topics {
$mid = delete $seen->{$subj};
my @subj = split(/ /, $srch->subject_normalized($subj));
my @next_prev = @subj; # full copy
- my $omit = ''; # '"' denotes identical text omitted
- while (@$prev_subj && @subj &&
- $subj[-1] eq $prev_subj->[-1]) {
- pop @$prev_subj;
- pop @subj;
- $omit ||= ' "';
- }
- pop @subj if @subj && $subj[-1] =~ /^re:\s*/i;
+ my $omit = dedupe_subject($prev_subj, \@subj, ' "');
$prev_subj = \@next_prev;
$subj = ascii_html(join(' ', @subj));
obfuscate_addrs($obfs_ibx, $subj) if $obfs_ibx;
--
EW
reply other threads:[~2017-12-21 1:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171221010012.23680-1-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).