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-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE 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 4FB321F6AC for ; Sat, 10 Sep 2022 08:18:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1662797938; bh=aB8CPbglMh9h2Hz5ISHe5lO2+BUIwed1GYpat1ycsl8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=1MIkBQ3cCQJQHoS3As2lnaA3of2v3YODMbqgaYlRgAD0m7AwegwrbCOPuoY6ZyrZC uae+KWC6MTLX/2Vu5HbV78E2zJyAAYszSn13w08FjmtAREOHEB2yA+eOPJh/JLKqpQ bUqFb5PF6jNpASiMa9+SNSo+oufHqPgyIb53Y6rc= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 36/38] mbox*: use multi-arg ->translate and ->write Date: Sat, 10 Sep 2022 08:17:27 +0000 Message-Id: <20220910081729.2011934-37-e@80x24.org> In-Reply-To: <20220910081729.2011934-1-e@80x24.org> References: <20220910081729.2011934-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: No need to make multiple method calls from here, now that ->translate and GzipFilter->write both support multiple args. --- lib/PublicInbox/Mbox.pm | 11 ++++------- 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};