* [PATCH 3/8] overidx: inline create_ghost sub
2020-08-27 12:16 6% [PATCH 0/8] mostly watch-related odds and ends Eric Wong
@ 2020-08-27 12:17 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-08-27 12:17 UTC (permalink / raw)
To: meta
There's no need for this to be a separate sub since there's
only a single caller. This saves a few kilobytes at least
in short-lived processes.
---
lib/PublicInbox/OverIdx.pm | 23 ++++++++++-------------
t/over.t | 4 ++--
2 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/lib/PublicInbox/OverIdx.pm b/lib/PublicInbox/OverIdx.pm
index 67f8cf65..6f0477f0 100644
--- a/lib/PublicInbox/OverIdx.pm
+++ b/lib/PublicInbox/OverIdx.pm
@@ -184,23 +184,20 @@ sub resolve_mid_to_tid {
if (my $del = delete $self->{-ghosts_to_delete}) {
delete_by_num($self, $_) for @$del;
}
- $tid // create_ghost($self, $mid);
-}
-
-sub create_ghost {
- my ($self, $mid) = @_;
- my $id = mid2id($self, $mid);
- my $num = next_ghost_num($self);
- $num < 0 or die "ghost num is non-negative: $num\n";
- my $tid = next_tid($self);
- my $dbh = $self->{dbh};
- $dbh->prepare_cached(<<'')->execute($num, $tid);
+ $tid // do { # create a new ghost
+ my $id = mid2id($self, $mid);
+ my $num = next_ghost_num($self);
+ $num < 0 or die "ghost num is non-negative: $num\n";
+ $tid = next_tid($self);
+ my $dbh = $self->{dbh};
+ $dbh->prepare_cached(<<'')->execute($num, $tid);
INSERT INTO over (num, tid) VALUES (?,?)
- $dbh->prepare_cached(<<'')->execute($id, $num);
+ $dbh->prepare_cached(<<'')->execute($id, $num);
INSERT INTO id2num (id, num) VALUES (?,?)
- $tid;
+ $tid;
+ };
}
sub merge_threads {
diff --git a/t/over.t b/t/over.t
index 41c13872..4c8f8098 100644
--- a/t/over.t
+++ b/t/over.t
@@ -33,9 +33,9 @@ $over->dbh;
is($over->sid('hello-world'), $x, 'idempotent across reopen');
$over->each_by_mid('never', sub { fail('should not be called') });
-$x = $over->create_ghost('never');
+$x = $over->resolve_mid_to_tid('never');
is(int($x), $x, 'integer tid for ghost');
-$y = $over->create_ghost('NEVAR');
+$y = $over->resolve_mid_to_tid('NEVAR');
is($y, $x + 1, 'integer tid for ghost increases');
my $ddd = compress('');
^ permalink raw reply related [relevance 7%]
* [PATCH 0/8] mostly watch-related odds and ends
@ 2020-08-27 12:16 6% Eric Wong
2020-08-27 12:17 7% ` [PATCH 3/8] overidx: inline create_ghost sub Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2020-08-27 12:16 UTC (permalink / raw)
To: meta
Mostly stuff around -watch, I've finally decided NNTP and IMAP
client support aren't as horrible-to-configure as I was
imagining. Well, maybe, at least I'm finding it somewhat
useful...
One problem I've been trying to avoid is having excessive,
overwhelming amounts of documentation. I tend to get
overwhelmed myself when learning new things, too.
Moving the watch-only stuff out of the config manpage seems like
a step in the right direction in that regard.
Eric Wong (8):
watchmaildir: ensure I:/W:/E: prefixes in warnings
imaptracker: preserve WAL journal_mode if set by user
overidx: inline create_ghost sub
doc: document graceful shutdown signals
doc: speling fickses
watch: imap: only remove \Seen spam
doc: move watch config docs to -watch manpage
doc: watch: expand on NNTP and IMAP-specific knobs
Documentation/public-inbox-config.pod | 38 ++--------
Documentation/public-inbox-edit.pod | 2 +-
Documentation/public-inbox-purge.pod | 2 +-
Documentation/public-inbox-tuning.pod | 2 +-
Documentation/public-inbox-watch.pod | 100 +++++++++++++++++++++++---
lib/PublicInbox/IMAPTracker.pm | 7 +-
lib/PublicInbox/OverIdx.pm | 23 +++---
lib/PublicInbox/WatchMaildir.pm | 31 +++++---
t/over.t | 4 +-
9 files changed, 135 insertions(+), 74 deletions(-)
^ permalink raw reply [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-08-27 12:16 6% [PATCH 0/8] mostly watch-related odds and ends Eric Wong
2020-08-27 12:17 7% ` [PATCH 3/8] overidx: inline create_ghost sub Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
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).