about summary refs log tree commit homepage
path: root/lib/PublicInbox/ViewVCS.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-08-29 09:26:34 +0000
committerEric Wong <e@80x24.org>2022-08-29 19:05:45 +0000
commit2231b44cd5726ce338ca6213300b4e8c74f1bcaa (patch)
tree6ab264975eb12af4323127ae83e944204db8d4b6 /lib/PublicInbox/ViewVCS.pm
parent95a3cace67ff5297e6fc35972e401b7cb17ee310 (diff)
downloadpublic-inbox-2231b44cd5726ce338ca6213300b4e8c74f1bcaa.tar.gz
This can avoid at least one expensive copy for displaying
large blobs with syntax highlighting.

However, we cannot blindly change everything to arrays, either:
the cost of invoking Compress::Raw::Zlib->deflate must be taken
into account.  Joining short strings via `.=', `.', `join' or
interpolation is typically faster since it avoids ->deflate
method calls (and non-magic perlops are the fastest dispatches
in Perl).
Diffstat (limited to 'lib/PublicInbox/ViewVCS.pm')
-rw-r--r--lib/PublicInbox/ViewVCS.pm16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm
index 23524ac0..8fb0844d 100644
--- a/lib/PublicInbox/ViewVCS.pm
+++ b/lib/PublicInbox/ViewVCS.pm
@@ -313,15 +313,15 @@ EOM
                 $$blob = ascii_html($$blob);
         }
 
-        # using some of the same CSS class names and ids as cgit
-        html_page($ctx, 200, "<pre>$oid $type $size bytes $raw_link</pre>" .
+        my $x = "<pre>$oid $type $size bytes $raw_link</pre>" .
                 "<hr /><table\nclass=blob>".
-                "<tr><td\nclass=linenumbers><pre>" . join('', map {
-                        sprintf("<a id=n$_ href=#n$_>% ${pad}u</a>\n", $_)
-                } (1..$nl)) . '</pre></td>' .
-                '<td><pre> </pre></td>'. # pad for non-CSS users
-                "<td\nclass=lines><pre\nstyle='white-space:pre'><code>" .
-                $ctx->{-linkify}->linkify_2($$blob) .
+                "<tr><td\nclass=linenumbers><pre>";
+        $x .= sprintf("<a id=n$_ href=#n$_>% ${pad}u</a>\n", $_) for (1..$nl);
+        $x .= '</pre></td><td><pre> </pre></td>'. # pad for non-CSS users
+                "<td\nclass=lines><pre\nstyle='white-space:pre'><code>";
+
+        # using some of the same CSS class names and ids as cgit
+        html_page($ctx, 200, $x, $ctx->{-linkify}->linkify_2($$blob),
                 '</code></pre></td></tr></table>'.dbg_log($ctx));
 }