From: Eric Wong Date: Mon, 1 Jun 2020 10:06:53 +0000 (+0000) Subject: nntp: smsg_range_i: favor ->{$field} lookups when possible X-Git-Tag: v1.6.0~473 X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=49ce43454cce10505d6aeea14521c03e6224a745 nntp: smsg_range_i: favor ->{$field} lookups when possible PublicInbox::Smsg::date remains the only exception which requires any subroutine calls, here, so we'll just have a branch just for that. --- diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index 54207500..a37910d1 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);