diff options
author | Eric Wong <e@yhbt.net> | 2020-06-01 10:06:53 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-06-03 04:04:21 +0000 |
commit | 49ce43454cce10505d6aeea14521c03e6224a745 (patch) | |
tree | ef9ff072cc12eadc8a1115af4db0b29b7e602a86 /lib/PublicInbox/NNTP.pm | |
parent | 7e782e8ff3ec64500913069a2efb5815fe711a36 (diff) | |
download | public-inbox-49ce43454cce10505d6aeea14521c03e6224a745.tar.gz |
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.
Diffstat (limited to 'lib/PublicInbox/NNTP.pm')
-rw-r--r-- | lib/PublicInbox/NNTP.pm | 12 |
1 files 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); |