From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/5] lei_to_mail: trim down imports
Date: Mon, 5 Apr 2021 10:27:48 +0000 [thread overview]
Message-ID: <20210405102752.6249-2-e@80x24.org> (raw)
In-Reply-To: <20210405102752.6249-1-e@80x24.org>
We don't need to import so many things. None of the Errno
constants are in common paths so unlikely to benefit from
constant folding.
---
lib/PublicInbox/LeiToMail.pm | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm
index 0364d8ef..76a11b0e 100644
--- a/lib/PublicInbox/LeiToMail.pm
+++ b/lib/PublicInbox/LeiToMail.pm
@@ -7,23 +7,15 @@ use strict;
use v5.10.1;
use parent qw(PublicInbox::IPC);
use PublicInbox::Eml;
-use PublicInbox::Lock;
use PublicInbox::ProcessPipe;
use PublicInbox::Spawn qw(spawn);
use PublicInbox::LeiDedupe;
-use PublicInbox::Git;
-use PublicInbox::GitAsyncCat;
use PublicInbox::PktOp qw(pkt_do);
use Symbol qw(gensym);
use IO::Handle; # ->autoflush
use Fcntl qw(SEEK_SET SEEK_END O_CREAT O_EXCL O_WRONLY);
-use Errno qw(EEXIST ESPIPE ENOENT EPIPE);
use Digest::SHA qw(sha256_hex);
-# struggles with short-lived repos, Gcf2Client makes little sense with lei;
-# but we may use in-process libgit2 in the future.
-$PublicInbox::GitAsyncCat::GCF2C = 0;
-
my %kw2char = ( # Maildir characters
draft => 'D',
flagged => 'F',
@@ -76,7 +68,7 @@ sub atomic_append { # for on-disk destinations (O_APPEND, or O_EXCL)
if (defined(my $w = syswrite($lei->{1} // return, $$buf))) {
return if $w == length($$buf);
$buf = "short atomic write: $w != ".length($$buf);
- } elsif ($! == EPIPE) {
+ } elsif ($!{EPIPE}) {
return $lei->note_sigpipe(1);
} else {
$buf = "atomic write: $!";
@@ -275,7 +267,7 @@ sub _buf2maildir {
do {
$tmp = $dst.'tmp/'.$rand.$common;
} while (!($ok = sysopen($fh, $tmp, O_CREAT|O_EXCL|O_WRONLY)) &&
- $! == EEXIST && ($rand = _rand.','));
+ $!{EEXIST} && ($rand = _rand.','));
if ($ok && print $fh $$buf and close($fh)) {
# ignore new/ and write only to cur/, otherwise MUAs
# with R/W access to the Maildir will end up doing
@@ -285,7 +277,7 @@ sub _buf2maildir {
$rand = '';
do {
$final = $dst.$rand.$common.':2,'.$sfx;
- } while (!($ok = link($tmp, $final)) && $! == EEXIST &&
+ } while (!($ok = link($tmp, $final)) && $!{EEXIST} &&
($rand = _rand.','));
die "link($tmp, $final): $!" unless $ok;
unlink($tmp) or warn "W: failed to unlink $tmp: $!\n";
@@ -473,7 +465,7 @@ sub _pre_augment_mbox {
}
# Perl does SEEK_END even with O_APPEND :<
$self->{seekable} = seek($out, 0, SEEK_SET);
- if (!$self->{seekable} && $! != ESPIPE && !defined($devfd)) {
+ if (!$self->{seekable} && !$!{ESPIPE} && !defined($devfd)) {
die "seek($dst): $!\n";
}
if (!$self->{seekable}) {
@@ -610,7 +602,7 @@ sub poke_dst {
sub write_mail { # via ->wq_io_do
my ($self, $smsg) = @_;
- git_async_cat($self->{lei}->{ale}->git, $smsg->{blob}, \&git_to_mail,
+ $self->{lei}->{ale}->git->cat_async($smsg->{blob}, \&git_to_mail,
[$self->{wcb}, $smsg]);
}
next prev parent reply other threads:[~2021-04-05 10:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-05 10:27 [PATCH 0/5] lei_to_mail fixes Eric Wong
2021-04-05 10:27 ` Eric Wong [this message]
2021-04-05 10:27 ` [PATCH 2/5] lei_tag: fix comments w.r.t support levels Eric Wong
2021-04-05 10:27 ` [PATCH 3/5] lei: maildir: move shard support to MdirReader Eric Wong
2021-04-05 10:27 ` [PATCH 4/5] lei_to_mail: improve comments and reduce LoC Eric Wong
2021-04-05 10:27 ` [PATCH 5/5] lei q: fix auth IMAP --output with remote mboxrd Eric Wong
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
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210405102752.6249-2-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
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).