* [PATCH 2/4] view: stop chomping off whitespace at ends of messages
2016-12-24 11:52 5% [PATCH 0/4] HTML micro-optimizations Eric Wong
@ 2016-12-24 11:52 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2016-12-24 11:52 UTC (permalink / raw)
To: meta
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(-)
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index cf40b55..97a8bcb 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 {
--
EW
^ permalink raw reply related [relevance 7%]
* [PATCH 0/4] HTML micro-optimizations
@ 2016-12-24 11:52 5% Eric Wong
2016-12-24 11:52 7% ` [PATCH 2/4] view: stop chomping off whitespace at ends of messages Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2016-12-24 11:52 UTC (permalink / raw)
To: meta
Testing with a horriblely long 368-message thread on git@vger,
I've found some minor tweaks which give us some tiny speedups.
Unfortunately, these are minor and new features may end up
costing us more in the future. Further optimizations are
needed.
Eric Wong (4):
view: remove unused parameter
view: stop chomping off whitespace at ends of messages
view: do not modify array during iteration
linkify: modify argument in place
lib/PublicInbox/Linkify.pm | 17 +++++++----------
lib/PublicInbox/View.pm | 21 +++++++++------------
2 files changed, 16 insertions(+), 22 deletions(-)
^ permalink raw reply [relevance 5%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-12-24 11:52 5% [PATCH 0/4] HTML micro-optimizations Eric Wong
2016-12-24 11:52 7% ` [PATCH 2/4] view: stop chomping off whitespace at ends of messages 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).