unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Subject: [PATCH] msgmap: do not cache num_highwater
Date: Sat, 16 Oct 2021 19:11:33 +0000	[thread overview]
Message-ID: <20211016191133.30859-1-e@80x24.org> (raw)

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   | 3 +--
 lib/PublicInbox/Msgmap.pm | 7 +++----
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index 41bcf9af..4a7ff2f4 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -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;
diff --git a/lib/PublicInbox/Msgmap.pm b/lib/PublicInbox/Msgmap.pm
index e71f16f8..699a8bf0 100644
--- a/lib/PublicInbox/Msgmap.pm
+++ b/lib/PublicInbox/Msgmap.pm
@@ -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 {

                 reply	other threads:[~2021-10-16 19:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211016191133.30859-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=ebiederm@xmission.com \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).