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 0AC241F66E for ; Sat, 10 Sep 2022 08:18:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1662797937; bh=mRlJL/v4LLj1l4jUjBaoOuhYRXvb8oXCngRwu7Wfm3M=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dUDE96jcm6jXUgNrETq3withAmw57/6WIIA4I4SINTPA33HwKHfqckAWh1GnEJvYy +SXOnBLtKFV3+eKiW53cwuY/k/p6isi9Umc6HWfcoboHs4jc6KH6c298Xqc7eXwxKw UvR4BJyFJvoWsR486NYSMVVUqid2zBd8Ra4riOlg= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 29/38] viewdiff: diff_before_or_after: avoid extra capture Date: Sat, 10 Sep 2022 08:17:20 +0000 Message-Id: <20220910081729.2011934-30-e@80x24.org> In-Reply-To: <20220910081729.2011934-1-e@80x24.org> References: <20220910081729.2011934-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: /(.*?)\z/ will capture the "$X insertions(+), $Y deletions(-)" bit anyways, along with whatever extra notes before the /^diff --git / line. So just rely on /(.*?)\z/ and avoid the special case before it. --- lib/PublicInbox/ViewDiff.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm index 5d23881b..b9115669 100644 --- a/lib/PublicInbox/ViewDiff.pm +++ b/lib/PublicInbox/ViewDiff.pm @@ -162,9 +162,9 @@ sub diff_before_or_after ($$) { if (exists $ctx->{-anchors} && $$x =~ /\A(.*?) # likely "---\n" # \$1 # diffstat lines: ((?:^\x20(?:[^\n]+?)(?:\x20+\|\x20[^\n]*\n))+) - (\x20[0-9]+\x20files?\x20)changed,([^\n]+\n) + (\x20[0-9]+\x20files?\x20)changed, (.*?)\z/msx) { # notes, commit message, etc - my @x = ($5, $4, $3, $2, $1); + my @x = ($4, $3, $2, $1); undef $$x; my $lnk = $ctx->{-linkify}; my $zfh = $ctx->{zfh}; @@ -177,8 +177,8 @@ sub diff_before_or_after ($$) { my $ch = $ctx->{changed_href} // '#related'; print $zfh pop(@x), # $3 /^ \d+ files? / qq(changed,), - ascii_html(pop @x), # insertions/deletions - $lnk->to_html(@x); # notes, commit message, etc + # insertions/deletions, notes, commit message, etc: + $lnk->to_html(@x); } else { print { $ctx->{zfh} } $ctx->{-linkify}->to_html($$x); }