From: Eric Wong Date: Mon, 29 Aug 2022 09:26:34 +0000 (+0000) Subject: viewvcs: use array for highlighted blob display X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=2231b44cd5726ce338ca6213300b4e8c74f1bcaa;p=public-inbox.git viewvcs: use array for highlighted blob display 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). --- 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, "
$oid $type $size bytes $raw_link
" . + my $x = "
$oid $type $size bytes $raw_link
" . "
". - "
" . join('', map {
-			sprintf("% ${pad}u\n", $_)
-		} (1..$nl)) . '
' . - '
 
'. # pad for non-CSS users - "" . - $ctx->{-linkify}->linkify_2($$blob) . + "
";
+	$x .= sprintf("% ${pad}u\n", $_) for (1..$nl);
+	$x .= '
 
'. # pad for non-CSS users + ""; + + # using some of the same CSS class names and ids as cgit + html_page($ctx, 200, $x, $ctx->{-linkify}->linkify_2($$blob), ''.dbg_log($ctx)); }