Compute buttons only once

$q->self_url is surprisingly slow, so don't call it gratuitously.
This commit is contained in:
Peter J. Holzer 2018-03-20 19:56:45 +01:00
parent a324ce4a65
commit 1bbef0d1bc
1 changed files with 8 additions and 7 deletions

View File

@ -280,18 +280,19 @@ sub print_itemlist {
$html .= "<div class='$item_class' $langattr>\n";
$html .= "<span class='itemno'>" . $item->{item_id} . "</span>\n";
$html .= "<span class='issued'>" . strftime('%Y-%m-%d %H:%M:%S', localtime($item->{issued})) . "</span>\n";
my $mark_read_button = "";
my $mark_later_button = "";
unless ($is_read) {
print_log("print_itemlist: \$q1=" . $q1->self_url . " (in loop)");
$html .= "<div class='op'><a href='" . $q->escapeHTML($q1->self_url) . "'>Mark read</a></div>\n";
$html .= "<div class='op'><a href='" . $q->escapeHTML($q_later->self_url) . "'>Show later</a></div>\n";
$mark_read_button = "<div class='op'><a href='" . $q->escapeHTML($q1->self_url) . "'>Mark read</a></div>\n";
$mark_later_button = "<div class='op'><a href='" . $q->escapeHTML($q_later->self_url) . "'>Show later</a></div>\n";
}
$html .= $mark_read_button;
$html .= $mark_later_button;
$html .= "<div class='feed'>" . $q->escapeHTML($item->{feed_title}) . "</div>\n";
$html .= "<h2><a href='./?redir=" . $q->escapeHTML($item->{item_id}) . "'>" . $q->escapeHTML($item->{item_title}) . "</a></h2>\n";
$html .= "<div class='content'>" . $scrubbed_content . "</div>\n";
unless ($is_read) {
$html .= "<div class='op'><a href='" . $q->escapeHTML($q1->self_url) . "'>Mark read</a></div>\n";
$html .= "<div class='op'><a href='" . $q->escapeHTML($q_later->self_url) . "'>Show later</a></div>\n";
}
$html .= $mark_read_button;
$html .= $mark_later_button;
$html .= "<div class='end'></div>\n";
$html .= "</div\n>";
print $html;