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 56F761F622 for ; Sat, 10 Sep 2022 08:18:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1662797933; bh=DCZc1AcrtGN2aHeZMuXgtX+xhaQyikuM1AVjRFLyWvE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NXRybn6MCgyeSVKOCGhPgpFzXhKxOBeDkiptLYcg8qOUDsHvy47QOPnVpLcw3M+dN YW+J5LwfbqRoabVsCq1+pnq+59Ag37uQIQqYNTLcKbMHIRDU0S7Yk4AsuKlzkghxKr OK1DpnE64z52lVTdj4Xr6nbSZS0XTs0R9yXEfE18= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 09/38] www_listing: avoid unnecessary work for common cases Date: Sat, 10 Sep 2022 08:17:00 +0000 Message-Id: <20220910081729.2011934-10-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 need to branch for non-empty `q=' parameters anyways, but `q=' is usually empty/unset. While we're in the area, `chomp' reads `$/' while `chop' is simpler. Furthermore, we can shave a few bytes off the form HTML by omitting spaces before `/>' and placing `\n' to wrap long lines before attribute names. --- lib/PublicInbox/WwwListing.pm | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm index 0ab41452..35abf050 100644 --- a/lib/PublicInbox/WwwListing.pm +++ b/lib/PublicInbox/WwwListing.pm @@ -169,17 +169,15 @@ sub mset_nav_top { my ($ctx, $mset) = @_; my $q = $ctx->{-sq}; my $qh = $q->{'q'} // ''; - utf8::decode($qh); - $qh = ascii_html($qh); - $qh = qq[\nvalue="$qh"] if $qh ne ''; - my $rv = <
+	if ($qh ne '') {
+		utf8::decode($qh);
+		$qh = qq[\nvalue="].ascii_html($qh).'"';
+	}
+	chop(my $rv = <
 EOM
-	chomp $rv;
 	if (defined($q->{'q'})) {
 		my $initial_q = $ctx->{-uxs_retried};
 		if (defined $initial_q) {