]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
treewide: use ->close method rather than CORE::close
authorEric Wong <e@80x24.org>
Thu, 2 Nov 2023 09:35:28 +0000 (09:35 +0000)
committerEric Wong <e@80x24.org>
Thu, 2 Nov 2023 23:46:54 +0000 (23:46 +0000)
It's easier-to-read and should open the door for us to get rid
of `tie' for ProcessIO without performance penalties for
more frequently-used perlop calls and ability to do `stat' directly
on the object instead of the awkward `tied' thing.

lib/PublicInbox/CodeSearchIdx.pm
lib/PublicInbox/DS.pm
lib/PublicInbox/DirIdle.pm
lib/PublicInbox/Git.pm
lib/PublicInbox/HTTP.pm
lib/PublicInbox/LeiMirror.pm

index bf41073441a2607b52044164db3ec5dbbf5575d7..c1a1ee90377ef21f9e25f5c48ad5627d7a7abd97 100644 (file)
@@ -480,11 +480,11 @@ sub partition_refs ($$$) {
                        $seen = 0;
                }
                if ($DO_QUIT) {
-                       CORE::close($rfh);
+                       $rfh->close;
                        return ();
                }
        }
-       CORE::close($rfh);
+       $rfh->close;
        return () if $DO_QUIT;
        if (!$? || (($? & 127) == POSIX::SIGPIPE && $seen > $SEEN_MAX)) {
                my $n = $NCHANGE - $n0;
@@ -887,7 +887,7 @@ sub associate {
                        ++$score{"$ibx_id $_"} for @root_ids;
                }
        }
-       CORE::close $rd or die "@join failed: $?=$?";
+       $rd->close or die "fatal: @join failed: \$?=$?";
        my $min = $self->{-opt}->{'assoc-min'} // 10;
        progress($self, scalar(keys %score).' potential pairings...');
        for my $k (keys %score) {
index 8331da95f90c91ef224753e40486293eef7391e4..33f80087792f0769de43e6ce13c5f05f3617d44b 100644 (file)
@@ -341,8 +341,8 @@ sub greet {
        my $ev = EPOLLIN;
        my $wbuf;
        if ($sock->can('accept_SSL') && !$sock->accept_SSL) {
-               return CORE::close($sock) if $! != EAGAIN;
-               $ev = PublicInbox::TLS::epollbit() or return CORE::close($sock);
+               return $sock->close if $! != EAGAIN;
+               $ev = PublicInbox::TLS::epollbit() or return $sock->close;
                $wbuf = [ \&accept_tls_step, $self->can('do_greet')];
        }
        new($self, $sock, $ev | EPOLLONESHOT);
index de6f229b5b46bd1af6616ed9cd92c5660a688f2b..e6a326ab630eb4176feb77a568b39dd5b850f7e2 100644 (file)
@@ -89,7 +89,7 @@ sub force_close {
        my ($self) = @_;
        my $inot = delete $self->{inot} // return;
        if ($inot->can('fh')) { # Linux::Inotify2 2.3+
-               CORE::close($inot->fh) or warn "CLOSE ERROR: $!";
+               $inot->fh->close or warn "CLOSE ERROR: $!";
        } elsif ($inot->isa('Linux::Inotify2')) {
                require PublicInbox::LI2Wrap;
                PublicInbox::LI2Wrap::wrapclose($inot);
index 191e4eea41e46d09c6731b6f3ade7da4b904488b..3dac32be594be03f63756b1ce945a38e582c941b 100644 (file)
@@ -441,12 +441,12 @@ sub qx {
        my $fh = popen(@_);
        if (wantarray) {
                my @ret = <$fh>;
-               CORE::close $fh; # caller should check $?
+               $fh->close; # caller should check $?
                @ret;
        } else {
                local $/;
                my $ret = <$fh>;
-               CORE::close $fh; # caller should check $?
+               $fh->close; # caller should check $?
                $ret;
        }
 }
@@ -621,7 +621,7 @@ sub manifest_entry {
                }
        }
        $ent->{fingerprint} = sha_all(1, $sr)->hexdigest;
-       CORE::close $sr or return; # empty, uninitialized git repo
+       $sr->close or return; # empty, uninitialized git repo
        $ent->{modified} = modified(undef, $mod);
        chomp($buf = <$own> // '');
        utf8::decode($buf);
index edc88fe8bf0b2a6a7b43c2df6457eacd8467c8b6..85991ae72b8454ccbdd39b3c9d86a264df9c38f8 100644 (file)
@@ -63,8 +63,8 @@ sub new ($$$) {
        my $ev = EPOLLIN;
        my $wbuf;
        if ($sock->can('accept_SSL') && !$sock->accept_SSL) {
-               return CORE::close($sock) if $! != EAGAIN;
-               $ev = PublicInbox::TLS::epollbit() or return CORE::close($sock);
+               return $sock->close if $! != EAGAIN;
+               $ev = PublicInbox::TLS::epollbit() or return $sock->close;
                $wbuf = [ \&PublicInbox::DS::accept_tls_step ];
        }
        $self->{wbuf} = $wbuf if $wbuf;
index 0f378768ac1b7a369acfa7b9ee236fa049f03855..71f41a11b7118efba7bced3d3b2e324704fff6b7 100644 (file)
@@ -334,7 +334,7 @@ sub fgrp_update {
                        upr($lei, $w, 'create', $ref, $oid);
                }
        }
-       CORE::close($w) or upref_warn();
+       $w->close or upref_warn();
 }
 
 sub satellite_done {
@@ -344,7 +344,7 @@ sub satellite_done {
                while (my ($ref, $oid) = each %$create) {
                        upr($fgrp->{lei}, $w, 'create', $ref, $oid);
                }
-               CORE::close($w) or upref_warn();
+               $w->close or upref_warn();
        } else {
                pack_refs($fgrp, $fgrp->{cur_dst});
                run_puh($fgrp);