diff options
author | Eric Wong <e@80x24.org> | 2020-12-16 23:19:04 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2020-12-17 19:41:14 +0000 |
commit | dbf250d9423ccc38377c35eef8d43e3e11723253 (patch) | |
tree | 9d29ec1355eae9bb8e46981ecd181074f4809cf8 /lib/PublicInbox/V2Writable.pm | |
parent | 519f80bb052a446ffa604a0862a631d846f64468 (diff) | |
download | public-inbox-dbf250d9423ccc38377c35eef8d43e3e11723253.tar.gz |
Perl readdir detects list context and can return an array suitable for the grep op. From there, we can rely on substr to remove the ".git" suffix and integerize the value to save a few bytes before letting List::Util::max return the value. This is how we detect Xapian shards nowadays, too, and we'll also use defined-or (//) to simplify the return value there. We'll also simplify InboxWritable->git_dir_latest, remove some callers, and consider removing it entirely.
Diffstat (limited to 'lib/PublicInbox/V2Writable.pm')
-rw-r--r-- | lib/PublicInbox/V2Writable.pm | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 992305c5..7b8b5abf 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -128,12 +128,9 @@ sub init_inbox { } $self->idx_init; $self->{mm}->skip_artnum($skip_artnum) if defined $skip_artnum; - my $epoch_max = -1; - $self->{ibx}->git_dir_latest(\$epoch_max); - if (defined $skip_epoch && $epoch_max == -1) { - $epoch_max = $skip_epoch; - } - $self->git_init($epoch_max >= 0 ? $epoch_max : 0); + my $max = $self->{ibx}->max_git_epoch; + $max = $skip_epoch if (defined($skip_epoch) && !defined($max)); + $self->git_init($max // 0); $self->done; } @@ -336,12 +333,7 @@ sub _replace_oids ($$$) { my $ibx = $self->{ibx}; my $pfx = "$ibx->{inboxdir}/git"; my $rewrites = []; # epoch => commit - my $max = $self->{epoch_max}; - - unless (defined($max)) { - defined(my $latest = $ibx->git_dir_latest(\$max)) or return; - $self->{epoch_max} = $max; - } + my $max = $self->{epoch_max} //= $ibx->max_git_epoch // return; foreach my $i (0..$max) { my $git_dir = "$pfx/$i.git"; |