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.2 required=3.0 tests=ALL_TRUSTED,AWL,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.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id B3B221F513 for ; Thu, 2 Nov 2023 09:35:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1698917741; bh=roV2dZya48Ch8dkuEFPfWZ9vwUgARrhL7DscVnjEpRc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=u/ZpwWppwIXsI329INCnS6JwZ0Q4DxxHcNWthSRuQpF7Vza6k670/Ty48lT3+HeLn wOg43lOoeK/4/LI7SNm0dL2uEDnX9VGbDHPH5DqQU1gw6QOU0cw9YJ22H+S9Y/AAXb QwtPA8uwMZu5irqlsk8e4As3P7+1M8LSA52J/bB8= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 04/14] cindex: drop redundant close on regular FH Date: Thu, 2 Nov 2023 09:35:29 +0000 Message-Id: <20231102093539.2067470-5-e@80x24.org> In-Reply-To: <20231102093539.2067470-1-e@80x24.org> References: <20231102093539.2067470-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: There's no need to waste optree space on close() statements for file handles which are (effectively) read-only on their last use and incapable of error checking in our Perl code (since they're only read by git). Let Perl refcounting take care of it so we have less code to wade through when focusing on `close' statements which actually matter. --- lib/PublicInbox/CodeSearchIdx.pm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/PublicInbox/CodeSearchIdx.pm b/lib/PublicInbox/CodeSearchIdx.pm index c1a1ee90..ad915fa2 100644 --- a/lib/PublicInbox/CodeSearchIdx.pm +++ b/lib/PublicInbox/CodeSearchIdx.pm @@ -268,7 +268,6 @@ sub shard_index { # via wq_io_do in IDX_SHARDS my $cmd = $git->cmd(@LOG_STDIN); my $rd = popen_rd($cmd, undef, { 0 => $in }, \&cidx_reap_log, $cmd, $self, $op_p); - close $in; PublicInbox::CidxLogP->new($rd, $self, $git, $roots); # CidxLogP->event_step will call cidx_read_log_p once there's input } @@ -457,7 +456,6 @@ sub partition_refs ($$$) { my ($self, $git, $refs) = @_; # show-ref --heads --tags --hash output sysseek($refs, 0, SEEK_SET); my $rfh = $git->popen(qw(rev-list --stdin), undef, { 0 => $refs }); - close $refs; my $seen = 0; my @shard_in = map { $_->reopen; @@ -971,7 +969,7 @@ sub dump_git_commits { # run_await cb (defined($pid) && $?) and die "E: @PRUNE_BATCH: \$?=$?"; return if $DO_QUIT; my ($hexlen) = keys(%ALT_FH) or return; # done - close(delete $ALT_FH{$hexlen}); + delete $ALT_FH{$hexlen}; $PRUNE_BATCH[1] = "--git-dir=$TMPDIR/hexlen$hexlen.git"; run_await(\@PRUNE_BATCH, undef, $batch_opt, \&dump_git_commits);