]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
eml: reuse ->decode buffer
authorEric Wong <e@80x24.org>
Tue, 13 Feb 2024 09:42:42 +0000 (09:42 +0000)
committerEric Wong <e@80x24.org>
Wed, 14 Feb 2024 07:26:12 +0000 (07:26 +0000)
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

index 56aec1e56345da84368cff4b5ec797749f602579..d59d7c3f64c42bb5518f300b278646eddb2f364a 100644 (file)
@@ -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;
 }