about summary refs log tree commit homepage
path: root/lib/PublicInbox/Config.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-05-15 06:31:49 +0000
committerEric Wong <e@80x24.org>2016-05-16 02:55:58 +0000
commitf22bbb56cf44c6864d53cf27746f9cafc12e05c1 (patch)
treec24ace20a79120b2b7078c42c24aca82dc05a6d2 /lib/PublicInbox/Config.pm
parent48b21cb662c1e17b7219612bff6ea14b98c85221 (diff)
downloadpublic-inbox-f22bbb56cf44c6864d53cf27746f9cafc12e05c1.tar.gz
This should make creating test cases easier and faster.
Diffstat (limited to 'lib/PublicInbox/Config.pm')
-rw-r--r--lib/PublicInbox/Config.pm9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index 3f3707ec..b5f0fcb1 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -15,9 +15,12 @@ use File::Path::Expand qw/expand_filename/;
 sub new {
         my ($class, $file) = @_;
         $file = default_file() unless defined($file);
-        my $self = bless git_config_dump($file), $class;
-        $self->{-by_addr} = {};
-        $self->{-by_name} = {};
+        $file = ref $file ? $file : git_config_dump($file);
+        my $self = bless $file, $class;
+
+        # caches
+        $self->{-by_addr} ||= {};
+        $self->{-by_name} ||= {};
         $self;
 }