about summary refs log tree commit homepage
path: root/lib/PublicInbox/Inbox.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-12-11 20:49:58 +0000
committerEric Wong <e@80x24.org>2020-12-14 20:25:23 +0000
commita80543303720bfe9c1293370ea2cafe98108a141 (patch)
treeea90e5b84fe6ecd64f92caf7369401c62a9f04a5 /lib/PublicInbox/Inbox.pm
parent4df1904582c4d7bec64e05d1566cd48c8c2e888e (diff)
downloadpublic-inbox-a80543303720bfe9c1293370ea2cafe98108a141.tar.gz
There's no need to have extra code in the Inbox package for this
or to waste dozens of bytes for every Inbox object which uses
the default value.

This makes our code more flexible w.r.t Inbox-like ExtSearch
objects and fixes uninitialized value warnings with ->ALL.
Diffstat (limited to 'lib/PublicInbox/Inbox.pm')
-rw-r--r--lib/PublicInbox/Inbox.pm17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index 586bd561..4e3c23f3 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -74,16 +74,6 @@ sub _cleanup_later ($) {
         $CLEANUP->{"$self"} = $self;
 }
 
-sub _set_uint ($$$) {
-        my ($opts, $field, $default) = @_;
-        my $val = $opts->{$field};
-        if (defined $val) {
-                $val = $val->[-1] if ref($val) eq 'ARRAY';
-                $val = undef if $val !~ /\A[0-9]+\z/;
-        }
-        $opts->{$field} = $val || $default;
-}
-
 sub _set_limiter ($$$) {
         my ($self, $pi_cfg, $pfx) = @_;
         my $lkey = "-${pfx}_limiter";
@@ -112,7 +102,12 @@ sub new {
         $opts->{domain} = ($p =~ /\@(\S+)\z/) ? $1 : 'localhost';
         my $pi_cfg = delete $opts->{-pi_cfg};
         _set_limiter($opts, $pi_cfg, 'httpbackend');
-        _set_uint($opts, 'feedmax', 25);
+        my $fmax = $opts->{feedmax};
+        if (defined($fmax) && $fmax =~ /\A[0-9]+\z/) {
+                $opts->{feedmax} += 0;
+        } else {
+                delete $opts->{feedmax};
+        }
         $opts->{nntpserver} ||= $pi_cfg->{'publicinbox.nntpserver'};
         my $dir = $opts->{inboxdir};
         if (defined $dir && -f "$dir/inbox.lock") {