From: Eric Wong Date: Sat, 25 Jan 2020 04:44:56 +0000 (+0000) Subject: wwwstream: discard single-use $ctx fields after use X-Git-Tag: v1.3.0~60 X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=c3d8c3df9f91aead9f6c24e1402b24e02c6a6def wwwstream: discard single-use $ctx fields after use 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. --- 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 ($) {