From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id E8DAD1FA17 for ; Tue, 1 Sep 2020 01:15:08 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 07/10] config: use defined-or (//) in a few places Date: Tue, 1 Sep 2020 01:15:04 +0000 Message-Id: <20200901011507.1643-8-e@80x24.org> In-Reply-To: <20200901011507.1643-1-e@80x24.org> References: <20200901011507.1643-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Just some golfing to reduce scrolling and hopefully readability. --- lib/PublicInbox/Config.pm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index f9184bd2..ae9ad8de 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -19,7 +19,7 @@ sub _array ($) { ref($_[0]) eq 'ARRAY' ? $_[0] : [ $_[0] ] } # if keys may be multi-value, the value is an array ref containing all values sub new { my ($class, $file) = @_; - $file = default_file() unless defined($file); + $file //= default_file(); my $self; if (ref($file) eq 'SCALAR') { # used by some tests open my $fh, '<', $file or die; # PerlIO::scalar @@ -136,9 +136,7 @@ sub limiter { sub config_dir { $ENV{PI_DIR} // "$ENV{HOME}/.public-inbox" } sub default_file { - my $f = $ENV{PI_CONFIG}; - return $f if defined $f; - config_dir() . '/config'; + $ENV{PI_CONFIG} // (config_dir() . '/config'); } sub config_fh_parse ($$$) {