about summary refs log tree commit homepage
path: root/lib/PublicInbox/Config.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-10-15 01:18:54 +0000
committerEric Wong <e@80x24.org>2019-10-15 20:26:41 +0000
commitfe3d294c237640bebf5d047c92921287a20d4485 (patch)
tree39064625f8254436025c9cd7a530d77c7d35c712 /lib/PublicInbox/Config.pm
parentb41c19abcf0b0ac8a5f55678bfb0058ad50b3179 (diff)
downloadpublic-inbox-fe3d294c237640bebf5d047c92921287a20d4485.tar.gz
'//' is available in Perl 5.10+ which allows `0' and `""' (empty
string) to remain unclobbered.

We also don't need '||=' for initializing our internal caches.
Diffstat (limited to 'lib/PublicInbox/Config.pm')
-rw-r--r--lib/PublicInbox/Config.pm28
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index 2b99346a..e0329ebf 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -29,13 +29,13 @@ sub new {
         }
         bless $self, $class;
         # caches
-        $self->{-by_addr} ||= {};
-        $self->{-by_list_id} ||= {};
-        $self->{-by_name} ||= {};
-        $self->{-by_newsgroup} ||= {};
-        $self->{-no_obfuscate} ||= {};
-        $self->{-limiters} ||= {};
-        $self->{-code_repos} ||= {}; # nick => PublicInbox::Git object
+        $self->{-by_addr} = {};
+        $self->{-by_list_id} = {};
+        $self->{-by_name} = {};
+        $self->{-by_newsgroup} = {};
+        $self->{-no_obfuscate} = {};
+        $self->{-limiters} = {};
+        $self->{-code_repos} = {}; # nick => PublicInbox::Git object
         $self->{-cgitrc_unparsed} = $self->{'publicinbox.cgitrc'};
 
         if (my $no = delete $self->{'publicinbox.noobfuscate'}) {
@@ -85,7 +85,7 @@ sub lookup_list_id {
 
 sub lookup_name ($$) {
         my ($self, $name) = @_;
-        $self->{-by_name}->{$name} || _fill($self, "publicinbox.$name");
+        $self->{-by_name}->{$name} // _fill($self, "publicinbox.$name");
 }
 
 sub each_inbox {
@@ -106,7 +106,7 @@ sub lookup_newsgroup {
 
 sub limiter {
         my ($self, $name) = @_;
-        $self->{-limiters}->{$name} ||= do {
+        $self->{-limiters}->{$name} //= do {
                 require PublicInbox::Qspawn;
                 my $max = $self->{"publicinboxlimiter.$name.max"} || 1;
                 my $limiter = PublicInbox::Qspawn::Limiter->new($max);
@@ -115,7 +115,7 @@ sub limiter {
         };
 }
 
-sub config_dir { $ENV{PI_DIR} || "$ENV{HOME}/.public-inbox" }
+sub config_dir { $ENV{PI_DIR} // "$ENV{HOME}/.public-inbox" }
 
 sub default_file {
         my $f = $ENV{PI_CONFIG};
@@ -206,8 +206,8 @@ sub cgit_repo_merge ($$$) {
                 $self->{-cgit_remove_suffix} and
                         $rel =~ s!/?\.git\z!!;
         }
-        $self->{"coderepo.$rel.dir"} ||= $path;
-        $self->{"coderepo.$rel.cgiturl"} ||= $rel;
+        $self->{"coderepo.$rel.dir"} //= $path;
+        $self->{"coderepo.$rel.cgiturl"} //= $rel;
 }
 
 sub is_git_dir ($) {
@@ -338,7 +338,7 @@ sub _fill_code_repo {
                 # cgit supports "/blob/?id=%s", but it's only a plain-text
                 # display and requires an unabbreviated id=
                 foreach my $t (qw(blob commit tag)) {
-                        $git->{$t.'_url_format'} ||= map {
+                        $git->{$t.'_url_format'} //= map {
                                 "$_/$t/?id=%s"
                         } @$cgits;
                 }
@@ -426,7 +426,7 @@ sub _fill {
                         $valid += valid_inbox_name($_) foreach (@parts);
                         $valid == scalar(@parts) or next;
 
-                        my $repo = $code_repos->{$nick} ||=
+                        my $repo = $code_repos->{$nick} //=
                                                 _fill_code_repo($self, $nick);
                         push @$repo_objs, $repo if $repo;
                 }