diff options
author | Eric Wong <e@80x24.org> | 2016-07-02 21:50:28 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-07-02 21:52:28 +0000 |
commit | 33cef7f24d3ddedc4cd79ee88b0bba6ed1aab4c9 (patch) | |
tree | 007d880f75e3d9ad06e732e098c2fa7d8b6fb72b /lib/PublicInbox/Config.pm | |
parent | db07ffcc3243a19ff5b6edf7f3bfc19cb7460df0 (diff) | |
download | public-inbox-33cef7f24d3ddedc4cd79ee88b0bba6ed1aab4c9.tar.gz |
This fills in the internal lookup hashes and simplifies callers.
Diffstat (limited to 'lib/PublicInbox/Config.pm')
-rw-r--r-- | lib/PublicInbox/Config.pm | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index ddb4f6b1..d34d11ad 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -50,11 +50,21 @@ sub lookup { _fill($self, $pfx); } -sub lookup_name { +sub lookup_name ($$) { my ($self, $name) = @_; - my $rv = $self->{-by_name}->{$name}; - return $rv if $rv; - $rv = _fill($self, "publicinbox.$name") or return; + $self->{-by_name}->{$name} || _fill($self, "publicinbox.$name"); +} + +sub each_inbox { + my ($self, $cb) = @_; + my %seen; + foreach my $k (keys %$self) { + $k =~ /\Apublicinbox\.([A-Z0-9a-z-]+)\.mainrepo\z/ or next; + next if $seen{$1}; + $seen{$1} = 1; + my $ibx = lookup_name($self, $1) or next; + $cb->($ibx); + } } sub lookup_newsgroup { |