From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH 8/8] treewide: use ->close method rather than CORE::close
Date: Fri, 27 Oct 2023 01:14:43 +0000 [thread overview]
Message-ID: <20231027011443.3709841-8-e@80x24.org> (raw)
In-Reply-To: <20231027011443.3709841-1-e@80x24.org>
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 `stat' usage.
---
lib/PublicInbox/CodeSearchIdx.pm | 6 +++---
lib/PublicInbox/DS.pm | 4 ++--
lib/PublicInbox/DirIdle.pm | 2 +-
lib/PublicInbox/Gcf2.pm | 2 +-
lib/PublicInbox/Git.pm | 6 +++---
lib/PublicInbox/HTTP.pm | 4 ++--
lib/PublicInbox/LeiMirror.pm | 6 +++---
7 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/lib/PublicInbox/CodeSearchIdx.pm b/lib/PublicInbox/CodeSearchIdx.pm
index bf410734..c1a1ee90 100644
--- a/lib/PublicInbox/CodeSearchIdx.pm
+++ b/lib/PublicInbox/CodeSearchIdx.pm
@@ -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) {
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index 6041c6b5..d8c84884 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -361,8 +361,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);
diff --git a/lib/PublicInbox/DirIdle.pm b/lib/PublicInbox/DirIdle.pm
index de6f229b..e6a326ab 100644
--- a/lib/PublicInbox/DirIdle.pm
+++ b/lib/PublicInbox/DirIdle.pm
@@ -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);
diff --git a/lib/PublicInbox/Gcf2.pm b/lib/PublicInbox/Gcf2.pm
index 4f163cde..81a1bae2 100644
--- a/lib/PublicInbox/Gcf2.pm
+++ b/lib/PublicInbox/Gcf2.pm
@@ -34,7 +34,7 @@ BEGIN {
for my $k (@switches) {
my $rd = popen_rd([$pc, "--$k", 'libgit2'], undef, $rdr);
chomp(my $val = do { local $/; <$rd> });
- CORE::close($rd) or last; # checks for error and sets $?
+ $rd->close or last; # checks for error and sets $?
$vals->{$k} = $val;
}
if (!$?) {
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index a1d52118..1f8ce1f0 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -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;
}
}
@@ -620,7 +620,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);
diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm
index edc88fe8..85991ae7 100644
--- a/lib/PublicInbox/HTTP.pm
+++ b/lib/PublicInbox/HTTP.pm
@@ -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;
diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm
index 43e59e6c..49b38d43 100644
--- a/lib/PublicInbox/LeiMirror.pm
+++ b/lib/PublicInbox/LeiMirror.pm
@@ -59,7 +59,7 @@ sub try_scrape {
my $opt = { 0 => $lei->{0}, 2 => $lei->{2} };
my $fh = popen_rd($cmd, undef, $opt);
my $html = do { local $/; <$fh> } // die "read(curl $uri): $!";
- CORE::close($fh) or return $lei->child_error($?, "@$cmd failed");
+ $fh->close or return $lei->child_error($?, "@$cmd failed");
# we grep with URL below, we don't want Subject/From headers
# making us clone random URLs. This assumes remote instances
@@ -335,7 +335,7 @@ sub fgrp_update {
upr($lei, $w, 'create', $ref, $oid);
}
}
- CORE::close($w) or upref_warn();
+ $w->close or upref_warn();
}
sub satellite_done {
@@ -345,7 +345,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);
prev parent reply other threads:[~2023-10-27 1:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-27 1:14 [PATCH 1/8] lei: don't exit lei-daemon on ovv_begin failure Eric Wong
2023-10-27 1:14 ` [PATCH 2/8] spawn: croak directly in C pi_fork_exec Eric Wong
2023-10-27 1:14 ` [PATCH 3/8] spawnpp: use autodie for syscall failures Eric Wong
2023-10-27 1:14 ` [PATCH 4/8] spawn: avoid alloca in C pi_fork_exec Eric Wong
2023-10-27 1:14 ` [PATCH 5/8] git: use run_qx to read `git --version' Eric Wong
2023-10-27 1:14 ` [PATCH 6/8] git: avoid extra stat(2) for git version Eric Wong
2023-10-27 1:14 ` [PATCH 7/8] import: use run_qx Eric Wong
2023-10-27 1:14 ` Eric Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231027011443.3709841-8-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).