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 97DE01F628 for ; Mon, 29 Aug 2022 09:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1661765209; bh=+I6ij18BkAR/2wsx2f9yMWzp/3hpKDNcKLWHUmgRGTM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GC57W/dgX/K4wEQ1eP5BvQUnUkMGOiHmR3Wm/SsWINNbHzB8LUv3Hhv7f8wAXuXG/ 9kD7e6c4xndMUcQ+IzD1hJyk6cLQdnXtcul62cD52/oiUMMnGvTso4kQBTAXb3Iu6c mv4JpljaHkqQcVvAh7DNrGwLAdIStQ9HIQtxQbJ8= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 16/18] viewvcs: reduce hash assignments for commit info Date: Mon, 29 Aug 2022 09:26:45 +0000 Message-Id: <20220829092647.1512215-17-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 makes some of the associated code less verbose and easier-to-read IMHO. --- lib/PublicInbox/ViewVCS.pm | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm index a5545bcd..0a38f9de 100644 --- a/lib/PublicInbox/ViewVCS.pm +++ b/lib/PublicInbox/ViewVCS.pm @@ -136,8 +136,7 @@ sub show_commit_start { # ->psgi_qx callback chop(my $buf = do { local $/ = "\0"; <$fh> }); chomp $buf; my ($P, $p); - ($P, $p, @$ctx{qw(cmt_H cmt_T cmt_s cmt_f cmt_au cmt_co cmt_b)}) - = split(/\n/, $buf, 9); + ($P, $p, @{$ctx->{cmt_info}}) = split(/\n/, $buf, 9); return cmt_finalize($ctx) if !$P; @{$ctx->{-cmt_P}} = split(/ /, $P); @{$ctx->{-cmt_p}} = split(/ /, $p); # abbreviated @@ -157,8 +156,8 @@ sub cmt_finalize { my ($ctx) = @_; $ctx->{-linkify} //= PublicInbox::Linkify->new; my $upfx = $ctx->{-upfx} = '../../'; # from "/$INBOX/$OID/s/" + my ($H, $T, $s, $f, $au, $co, $bdy) = @{delete $ctx->{cmt_info}}; # try to keep author and committer dates lined up - my ($au, $co) = delete @$ctx{qw(cmt_au cmt_co)}; my $x = length($au) - length($co); if ($x > 0) { $x = ' ' x $x; @@ -175,13 +174,12 @@ sub cmt_finalize { href="$upfx?t=$t" title="list contemporary emails">$2) !e; - my $s = $ctx->{-linkify}->to_html(delete $ctx->{cmt_s}); - $ctx->{-title_html} = $s; + $ctx->{-title_html} = $s = $ctx->{-linkify}->to_html($s); my ($P, $p, $pt) = delete @$ctx{qw(-cmt_P -cmt_p -cmt_pt)}; $_ = qq().shift(@$p).' '.shift(@$pt) for @$P; if (@$P == 1) { $x = qq{ (patch)\n parent $P->[0]}; +href="$f.patch">patch)\n parent $P->[0]}; } elsif (@$P > 1) { $x = qq(\n parents $P->[0]\n); shift @$P; @@ -192,29 +190,28 @@ href="$ctx->{cmt_f}.patch">patch)\n parent $P->[0]}; } PublicInbox::WwwStream::html_init($ctx); $ctx->zmore(< commit $ctx->{cmt_H}$x - tree $ctx->{cmt_T} +
   commit $H$x
+     tree $T
    author $au
 committer $co
 
 $s
 EOM
-	$x = delete $ctx->{cmt_b};
-	$ctx->zmore("\n", $ctx->{-linkify}->to_html($x)) if length($x);
-	undef $x;
+	$ctx->zmore("\n", $ctx->{-linkify}->to_html($bdy)) if length($bdy);
+	$bdy = '';
 	open my $fh, '<:utf8', "$ctx->{-tmp}/p" or
 		die "open $ctx->{-tmp}/p: $!";
 	if (-s $fh > $MAX_SIZE) {
 		$ctx->zmore("---\n patch is too large to show\n");
 	} else { # prepare flush_diff:
-		$ctx->{obuf} = \$x;
+		read($fh, $x, -s _);
+		$ctx->{obuf} = \$bdy;
 		$ctx->{-apfx} = $ctx->{-spfx} = $upfx;
-		read($fh, my $bdy, -s _);
-		$bdy =~ s/\r?\n/\n/gs;
-		$ctx->{-anchors} = {} if $bdy =~ /^diff --git /sm;
-		flush_diff($ctx, \$bdy); # undefs $bdy
-		$ctx->zmore($x);
-		undef $x;
+		$x =~ s/\r?\n/\n/gs;
+		$ctx->{-anchors} = {} if $x =~ /^diff --git /sm;
+		flush_diff($ctx, \$x); # undefs $x
+		$ctx->zmore($bdy);
+		undef $bdy;
 		# TODO: should there be another textarea which attempts to
 		# search for the exact email which was applied to make this
 		# commit?