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.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 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 A10B61F934 for ; Sat, 9 Oct 2021 12:03:36 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/4] solver_git: shorten scalar lifetimes Date: Sat, 9 Oct 2021 12:03:33 +0000 Message-Id: <20211009120336.2057-2-e@80x24.org> In-Reply-To: <20211009120336.2057-1-e@80x24.org> References: <20211009120336.2057-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Some of these scalar buffers may be large patches, so try to keep them as short-lived as possible to reduce memory pressure. --- lib/PublicInbox/SolverGit.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm index b0cd0f2c..5d5060f4 100644 --- a/lib/PublicInbox/SolverGit.pm +++ b/lib/PublicInbox/SolverGit.pm @@ -111,8 +111,6 @@ sub extract_diff ($$) { my ($self, $want, $smsg) = @$arg; my ($part) = @$p; # ignore $depth and @idx; my $ct = $part->content_type || 'text/plain'; - my ($s, undef) = msg_part_text($part, $ct); - defined $s or return; my $post = $want->{oid_b}; my $pre = $want->{oid_a}; if (!defined($pre) || $pre !~ /\A[a-f0-9]+\z/) { @@ -122,11 +120,12 @@ sub extract_diff ($$) { # Email::MIME::Encodings forces QP to be CRLF upon decoding, # change it back to LF: my $cte = $part->header('Content-Transfer-Encoding') || ''; + my ($s, undef) = msg_part_text($part, $ct); + defined $s or return; + delete $part->{bdy}; if ($cte =~ /\bquoted-printable\b/i && $part->crlf eq "\n") { $s =~ s/\r\n/\n/sg; } - - $s =~ m!( # $1 start header lines we save for debugging: # everything before ^index is optional, but we don't @@ -169,6 +168,7 @@ sub extract_diff ($$) { # because git-apply(1) handles that case, too (?:^(?:[\@\+\x20\-\\][^\n]*|)$LF)+ )!smx or return; + undef $s; # free memory my $di = { hdr_lines => $1,