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-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 19EE81FA0E for ; Mon, 1 Jun 2020 10:06:59 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 09/13] nntp: smsg_range_i: favor ->{$field} lookups when possible Date: Mon, 1 Jun 2020 10:06:53 +0000 Message-Id: <20200601100657.14700-10-e@yhbt.net> In-Reply-To: <20200601100657.14700-1-e@yhbt.net> References: <20200601100657.14700-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: PublicInbox::Smsg::date remains the only exception which requires any subroutine calls, here, so we'll just have a branch just for that. --- lib/PublicInbox/NNTP.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index 54207500dd8..a37910d1739 100644 --- a/lib/PublicInbox/NNTP.pm +++ b/lib/PublicInbox/NNTP.pm @@ -722,8 +722,16 @@ sub smsg_range_i { my $msgs = $over->query_xover($$beg, $end); scalar(@$msgs) or return; my $tmp = ''; - foreach my $s (@$msgs) { - $tmp .= $s->{num} . ' ' . $s->$field . "\r\n"; + + # ->{$field} is faster than ->$field invocations, so favor that. + if ($field eq 'date') { + for my $s (@$msgs) { + $tmp .= "$s->{num} ".PublicInbox::Smsg::date($s)."\r\n" + } + } else { + for my $s (@$msgs) { + $tmp .= "$s->{num} $s->{$field}\r\n"; + } } utf8::encode($tmp); $self->msg_more($tmp);