]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: cleaner killing of leading/trailing whitespace
authorEric Wong <e@80x24.org>
Sun, 16 Aug 2015 09:12:24 +0000 (09:12 +0000)
committerEric Wong <e@80x24.org>
Sun, 16 Aug 2015 09:19:10 +0000 (09:19 +0000)
No point in wasting bytes even if gets compressed over
the wire, it'll use more memory when rendering on the
client.

lib/PublicInbox/View.pm

index 660a112ff3c67633bad4cedf366321e89f951e54..e1632b5bec319fa6667925e79f9d31d50d30df0e 100644 (file)
@@ -142,14 +142,17 @@ sub index_walk {
        # Drop signatures
        $s =~ s/^-- \n.*\z//ms and $$more = 'more...';
 
-       # kill any leading or trailing whitespace
-       $s =~ s/\A\s+//s;
+       # kill any leading or trailing whitespace lines
+       $s =~ s/^[ \t]$//sgm;
        $s =~ s/\s+\z//s;
 
        if (length $s) {
                # add prefix:
                $s =~ s/^/$pfx/sgm;
 
+               # kill per-line trailing whitespace
+               $s =~ s/[ \t]+$//sgm;
+
                $rv .= $s . "\n";
        }
        $rv;