From f2bb17a54f42a276b993b7dd49c06239141eafe4 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 22 Feb 2023 17:25:55 +0000 Subject: treewide: simplify File::Path mkpath/make_path callers File::Path already accounts for the existence of directories, handles races from redundant mkdir(2), and croaks on unrecoverable errors. So there's no point in doing any of that on our end. Furthermore, avoiding the overhead of loading File::Path doesn't seem worth it to save 20-60ms given the overhead of loading our other code. Instead, try to reduce optree overhead on our code, instead, since File::Path gets used in a bunch of places. We'll also favor the newer make_path for multi-directory invocations to avoid bloating our own optree to create an arrayref, but mkpath is one fewer subroutine call within File::Path itself, right now. --- xt/imapd-mbsync-oimap.t | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'xt') diff --git a/xt/imapd-mbsync-oimap.t b/xt/imapd-mbsync-oimap.t index b0281105..f99779a1 100644 --- a/xt/imapd-mbsync-oimap.t +++ b/xt/imapd-mbsync-oimap.t @@ -4,7 +4,7 @@ # ensure mbsync and offlineimap compatibility use strict; use v5.10.1; -use File::Path qw(mkpath); +use File::Path qw(make_path); use PublicInbox::TestCommon; use PublicInbox::Spawn qw(spawn); require_mods(qw(-imapd)); @@ -41,7 +41,7 @@ my ($host, $port) = ($sock->sockhost, $sock->sockport); my %pids; SKIP: { - mkpath([map { "$tmpdir/oimapdir/$_" } qw(cur new tmp)]); + make_path(map { "$tmpdir/oimapdir/$_" } qw(cur new tmp)); my $oimap = require_cmd('offlineimap', 1) or skip 'no offlineimap(1)', 1; open my $fh, '>', "$tmpdir/.offlineimaprc" or BAIL_OUT "open: $!"; @@ -78,7 +78,7 @@ EOF } SKIP: { - mkpath([map { "$tmpdir/mbsyncdir/test/$_" } qw(cur new tmp)]); + make_path(map { "$tmpdir/mbsyncdir/test/$_" } qw(cur new tmp)); my $mbsync = require_cmd('mbsync', 1) or skip 'no mbsync(1)', 1; open my $fh, '>', "$tmpdir/.mbsyncrc" or BAIL_OUT "open: $!"; print $fh <