From 49ce43454cce10505d6aeea14521c03e6224a745 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 1 Jun 2020 10:06:53 +0000 Subject: 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. --- 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 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); -- cgit v1.2.3-24-ge0c7