]> Sergey Matveev's repositories - public-inbox.git/commitdiff
msgmap: do not cache num_highwater
authorEric Wong <e@80x24.org>
Sat, 16 Oct 2021 19:11:33 +0000 (19:11 +0000)
committerEric Wong <e@80x24.org>
Sun, 17 Oct 2021 00:48:17 +0000 (00:48 +0000)
Caching the value doesn't seem necessary from a performance
perspective, and it adds a caveat for read-only users which
may lead to bugs in future code.

lib/PublicInbox/IMAP.pm
lib/PublicInbox/Msgmap.pm

index 41bcf9af295de9d905f4dd5eb4d44a8e6938cecc..4a7ff2f457d0458c317d452764e6d20abb7d1734 100644 (file)
@@ -393,8 +393,7 @@ sub inbox_lookup ($$;$) {
                                die "BUG: unexpected dummy mailbox: $mailbox\n";
                $uid_base = $1 * UID_SLICE;
 
-               # ->num_highwater caches for writers, so use ->meta_accessor
-               $uidmax = $ibx->mm->meta_accessor('num_highwater') // 0;
+               $uidmax = $ibx->mm->num_highwater // 0;
                if ($examine) {
                        $self->{uid_base} = $uid_base;
                        $self->{ibx} = $ibx;
index e71f16f80ebd423343e467e2abeebe01d47e58fb..699a8bf0d9cda0d12ae618948f824c8a0c17f651 100644 (file)
@@ -100,13 +100,12 @@ sub created_at {
 
 sub num_highwater {
        my ($self, $num) = @_;
-       my $high = $self->{num_highwater} ||=
-           $self->meta_accessor('num_highwater');
+       my $high = $self->meta_accessor('num_highwater');
        if (defined($num) && (!defined($high) || ($num > $high))) {
-               $self->{num_highwater} = $num;
+               $high = $num;
                $self->meta_accessor('num_highwater', $num);
        }
-       $self->{num_highwater};
+       $high
 }
 
 sub mid_insert {