From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.1 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 7298F1F487 for ; Tue, 13 Feb 2024 09:42:43 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/2] eml: reuse ->decode buffer Date: Tue, 13 Feb 2024 09:42:42 +0000 Message-Id: <20240213094242.3496966-3-e@80x24.org> In-Reply-To: <20240213094242.3496966-1-e@80x24.org> References: <20240213094242.3496966-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: It's not really relevant at the moment, but a sufficiently smart implementation could eventually save some memory here. Perl already optimizes in-place sort (@x = sort @x), so there's precedent for a potential future where a Perl implementation could generally optimize in-place operations for non-builtin subroutines, too. --- lib/PublicInbox/Eml.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/Eml.pm b/lib/PublicInbox/Eml.pm index 56aec1e5..d59d7c3f 100644 --- a/lib/PublicInbox/Eml.pm +++ b/lib/PublicInbox/Eml.pm @@ -475,10 +475,10 @@ sub body_str { join("\n\t", header_raw($self, 'Content-Type'))); }; my $enc = find_encoding($cs) or croak "unknown encoding `$cs'"; - my $tmp = body($self); + my $ret = body($self); local @enc_warn; local $SIG{__WARN__} = $enc_warn; - my $ret = $enc->decode($tmp, Encode::FB_WARN); + $ret = $enc->decode($ret, Encode::FB_WARN); croak(@enc_warn) if @enc_warn; $ret; }