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 EB9D91F62B for ; Sat, 10 Sep 2022 08:18:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1662797934; bh=voLGlBcbG2COYmpScpiBlBQdx464kbk49+0GaDIAYtY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=51Go5/hwNvFLmlDDeXMUqZ5yzezRXc88zDCXoHyEx3hv3eKhI1s97hpK7NZsi+ede aiu56hy/48Huo6g4dnzuuC0doZfotBNKZCkd/VQrU7opR/06GmXDng/HetOy+BGl8O HcDD0ir7dYJAe2ycA84VwR9ulJl55m2WIUtFqLZQ= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 18/38] view: _th_index_lite: avoid one s///, improve symmetry Date: Sat, 10 Sep 2022 08:17:09 +0000 Message-Id: <20220910081729.2011934-19-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: We can replace an expensive `s///' substitution with a simpler `chop'. Furthermore, we can delay the "\n" replacement to ensure it's on the same line of Perl code as the `' opening tag for readability. --- lib/PublicInbox/View.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 0fe645ca..3282d4f9 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -335,10 +335,10 @@ sub _th_index_lite { } my $s_s = nr_to_s($nr_s, 'sibling', 'siblings'); my $s_c = nr_to_s($nr_c, 'reply', 'replies'); - $attr =~ s!\n\z!\n!s; + chop $attr; # remove "\n" $attr =~ s! (?:" )?!!s; # no point in dup subject $attr =~ s!]+>([^<]+)!$1!s; # no point linking to self - $rv .= "@ $attr"; + $rv .= "@ $attr\n"; if ($nr_c) { my $cmid = $children->[0] ? $children->[0]->{mid} : undef; $rv .= $pad . _skel_hdr($mapping, $cmid);