From 2e05c4503e44d4d9bf126589b7c6ba71db7ce94e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 24 Dec 2016 11:52:42 +0000 Subject: view: stop chomping off whitespace at ends of messages This allows a 3-4% speedup in $MESSAGE_ID/T/ page generation speed for a 368+ message thread. It also more faithfully preserves the message as intended; even if the it makes the sender look like a space-wasting slob :P --- lib/PublicInbox/View.pm | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index cf40b555..97a8bcbc 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -490,15 +490,13 @@ sub add_text_body { } } - my $end = "\n"; - if (@quot) { - $end = ''; + if (@quot) { # ugh, top posted flush_quote(\$s, $l, \@quot); + } elsif ($s =~ /\n\z/s) { # common, last line ends with a newline + $s; + } else { # some editors don't do newlines... + $s .= "\n"; } - $s =~ s/[ \t]+$//sgm; # kill per-line trailing whitespace - $s =~ s/\A\n+//s; # kill leading blank lines - $s =~ s/\s+\z//s; # kill all trailing spaces - $s .= $end; } sub _msg_html_prepare { -- cgit v1.2.3-24-ge0c7