diff options
author | Eric Wong <e@80x24.org> | 2022-09-10 08:17:27 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-09-10 19:50:56 +0000 |
commit | 0befaaa7b1ed2015fb5d6bf159db7d8972015f58 (patch) | |
tree | d8b65767c6602b99aed755ed9abba3ea96a7944a /lib/PublicInbox | |
parent | 27f50c13952376b7482280f16a6cd8e5dc421915 (diff) | |
download | public-inbox-0befaaa7b1ed2015fb5d6bf159db7d8972015f58.tar.gz |
mbox*: use multi-arg ->translate and ->write
No need to make multiple method calls from here, now that ->translate and GzipFilter->write both support multiple args.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/Mbox.pm | 11 | ||||
-rw-r--r-- | lib/PublicInbox/MboxGz.pm | 3 |
2 files changed, 5 insertions, 9 deletions
diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm index 2ef8ff2b..18db9d38 100644 --- a/lib/PublicInbox/Mbox.pm +++ b/lib/PublicInbox/Mbox.pm @@ -19,12 +19,10 @@ sub getline { my $smsg = $ctx->{smsg} or return; my $ibx = $ctx->{ibx}; my $eml = delete($ctx->{eml}) // $ibx->smsg_eml($smsg) // return; - my $n = $ctx->{smsg} = $ibx->over->next_by_mid(@{$ctx->{next_arg}}); - $ctx->zmore(msg_hdr($ctx, $eml)); - if ($n) { - $ctx->translate(msg_body($eml)); + if (($ctx->{smsg} = $ibx->over->next_by_mid(@{$ctx->{next_arg}}))) { + $ctx->translate(msg_hdr($ctx, $eml), msg_body($eml)); } else { # last message - $ctx->zflush(msg_body($eml)); + $ctx->zflush(msg_hdr($ctx, $eml), msg_body($eml)); } } @@ -45,8 +43,7 @@ sub async_eml { # for async_blob_cb # next message $ctx->{smsg} = $ctx->{ibx}->over->next_by_mid(@{$ctx->{next_arg}}); local $ctx->{eml} = $eml; # for mbox_hdr - $ctx->zmore(msg_hdr($ctx, $eml)); - $ctx->write(msg_body($eml)); + $ctx->write(msg_hdr($ctx, $eml), msg_body($eml)); } sub mbox_hdr ($) { diff --git a/lib/PublicInbox/MboxGz.pm b/lib/PublicInbox/MboxGz.pm index 56f5adcf..533d2ff1 100644 --- a/lib/PublicInbox/MboxGz.pm +++ b/lib/PublicInbox/MboxGz.pm @@ -37,8 +37,7 @@ sub getline { my $cb = $self->{cb} or return; while (my $smsg = $cb->($self)) { my $eml = $self->{ibx}->smsg_eml($smsg) or next; - $self->zmore(msg_hdr($self, $eml)); - return $self->translate(msg_body($eml)); + return $self->translate(msg_hdr($self, $eml), msg_body($eml)); } # signal that we're done and can return undef next call: delete $self->{cb}; |