From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 6DBC91F61C for ; Mon, 29 Aug 2022 09:26:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1661765208; bh=mCuXprHOQRiCBjnYRKa35IAILG8Mn3onDYS2bmpvghc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ntsv3+YZpQTlYOsLXgYa2M51WOTQPl6uDrJL/EJq5sGVPNMkKanSi5yNt9Et8F8ud K3IMRJxyDUMIvF9z8sbubDvA5gRq0bOY/2tNaoXw9nM5EV0nzxe49X17c23WXrcDwx 0GUL8ZIfrNI5FNAxFRM5FAEmJahd/VYtobqkBlj8= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 05/18] viewvcs: use array for highlighted blob display Date: Mon, 29 Aug 2022 09:26:34 +0000 Message-Id: <20220829092647.1512215-6-e@80x24.org> In-Reply-To: <20220829092647.1512215-1-e@80x24.org> References: <20220829092647.1512215-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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). --- lib/PublicInbox/ViewVCS.pm | 16 ++++++++-------- 1 file 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, "
$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)); }