From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 3ED5A1F670 for ; Fri, 28 Aug 2020 10:13:01 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/3] imaptracker: update_last: simplify callers Date: Fri, 28 Aug 2020 10:12:59 +0000 Message-Id: <20200828101300.17939-3-e@yhbt.net> In-Reply-To: <20200828101300.17939-1-e@yhbt.net> References: <20200828101300.17939-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: By making it a no-op if last_uid is not defined. This isn't a hot code path, so the extra method dispatch isn't an issue. It'll save some indentation/wrapping in future commits. --- lib/PublicInbox/IMAPTracker.pm | 5 +++-- lib/PublicInbox/WatchMaildir.pm | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/IMAPTracker.pm b/lib/PublicInbox/IMAPTracker.pm index 92f21584..be9caf76 100644 --- a/lib/PublicInbox/IMAPTracker.pm +++ b/lib/PublicInbox/IMAPTracker.pm @@ -49,13 +49,14 @@ SELECT uid_validity, uid FROM imap_last WHERE url = ? } sub update_last ($$$) { - my ($self, $validity, $last) = @_; + my ($self, $validity, $last_uid) = @_; + return unless defined $last_uid; my $sth = $self->{dbh}->prepare_cached(<<''); INSERT OR REPLACE INTO imap_last (url, uid_validity, uid) VALUES (?, ?, ?) $self->lock_acquire; - my $rv = $sth->execute($self->{url}, $validity, $last); + my $rv = $sth->execute($self->{url}, $validity, $last_uid); $self->lock_release; $rv; } diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm index 78aec8a2..a227a6fd 100644 --- a/lib/PublicInbox/WatchMaildir.pm +++ b/lib/PublicInbox/WatchMaildir.pm @@ -494,7 +494,7 @@ sub imap_fetch_all ($$$) { last if $self->{quit}; } _done_for_now($self); - $itrk->update_last($r_uidval, $last_uid) if defined $last_uid; + $itrk->update_last($r_uidval, $last_uid); } until ($err || $self->{quit}); $err; } @@ -919,7 +919,7 @@ sub nntp_fetch_all ($$$) { $last_art = $art; } _done_for_now($self); - $itrk->update_last(0, $last_art) if defined $last_art; + $itrk->update_last(0, $last_art); $err; }