]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Msgmap.pm
mm: min/max: return 0 instead of undef
[public-inbox.git] / lib / PublicInbox / Msgmap.pm
index f15875e37cd8a88c2b74956301892d4198be541f..a8c874af32487bcdd64bdc1b2d5ef1093e7ae933 100644 (file)
@@ -36,8 +36,7 @@ sub new_file {
                create_tables($dbh);
                $self->created_at(time) unless $self->created_at;
 
-               my $max = $self->max // 0;
-               $self->num_highwater($max);
+               $self->num_highwater(max($self));
                $dbh->commit;
        }
        $self;
@@ -144,7 +143,7 @@ sub max {
        my $sth = $_[0]->{dbh}->prepare_cached('SELECT MAX(num) FROM msgmap',
                                                undef, 1);
        $sth->execute;
-       $sth->fetchrow_array;
+       $sth->fetchrow_array // 0;
 }
 
 sub minmax {
@@ -153,7 +152,7 @@ sub minmax {
        my $sth = $_[0]->{dbh}->prepare_cached('SELECT MIN(num) FROM msgmap',
                                                undef, 1);
        $sth->execute;
-       ($sth->fetchrow_array, max($_[0]));
+       ($sth->fetchrow_array // 0, max($_[0]));
 }
 
 sub mid_delete {