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.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 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 576921FD52 for ; Sat, 25 Jan 2020 04:45:12 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 08/22] wwwstream: discard single-use $ctx fields after use Date: Sat, 25 Jan 2020 04:44:56 +0000 Message-Id: <20200125044510.13769-9-e@yhbt.net> In-Reply-To: <20200125044510.13769-1-e@yhbt.net> References: <20200125044510.13769-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This should make it clear that we only use these elements once and can discard them. While we're in the area, avoid escaping '"' by using qq() instead of "" to quote strings requiring interpolation. --- lib/PublicInbox/WwwStream.pm | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm index ef5897b2..a4ba1fff 100644 --- a/lib/PublicInbox/WwwStream.pm +++ b/lib/PublicInbox/WwwStream.pm @@ -40,25 +40,20 @@ sub _html_top ($) { my $ctx = $self->{ctx}; my $ibx = $ctx->{-inbox}; my $desc = ascii_html($ibx->description); - my $title = $ctx->{-title_html} || $desc; + my $title = delete($ctx->{-title_html}) // $desc; my $upfx = $ctx->{-upfx} || ''; my $help = $upfx.'_/text/help'; my $color = $upfx.'_/text/color'; my $atom = $ctx->{-atom} || $upfx.'new.atom'; - my $tip = $ctx->{-html_tip} || ''; my $top = "$desc"; my $links = "help / ". "color / ". "Atom feed"; if ($ibx->search) { - my $q_val = $ctx->{-q_value_html}; - if (defined $q_val && $q_val ne '') { - $q_val = qq(\nvalue="$q_val"); - } else { - $q_val = ''; - } + my $q_val = delete($ctx->{-q_value_html}) // ''; + $q_val = qq(\nvalue="$q_val") if $q_val ne ''; # XXX gross, for SearchView.pm - my $extra = $ctx->{-extra_form_html} || ''; + my $extra = delete($ctx->{-extra_form_html}) // ''; my $action = $upfx eq '' ? './' : $upfx; $top = qq{
$top} .
 			  qq{\n} .
@@ -70,10 +65,10 @@ sub _html_top ($) {
 		$top = '
' . $top . "\n" . $links . '
'; } "$title" . - "" . + qq() . $ctx->{www}->style($upfx) . - "". $top . $tip; + ''. $top . (delete($ctx->{-html_tip}) // ''); } sub code_footer ($) {