bless $opts, $class;
}
+sub version { $_[0]->{version} // 1 }
+
sub git_epoch {
my ($self, $epoch) = @_;
- ($self->{version} || 1) == 2 or return;
+ $self->version == 2 or return;
$self->{"$epoch.git"} ||= eval {
my $git_dir = "$self->{inboxdir}/git/$epoch.git";
my $g = PublicInbox::Git->new($git_dir);
my ($self) = @_;
$self->{git} ||= eval {
my $git_dir = $self->{inboxdir};
- $git_dir .= '/all.git' if (($self->{version} || 1) == 2);
+ $git_dir .= '/all.git' if $self->version == 2;
my $g = PublicInbox::Git->new($git_dir);
$g->{-httpbackend_limiter} = $self->{-httpbackend_limiter};
_cleanup_later($self);
sub max_git_epoch {
my ($self) = @_;
- my $v = $self->{version};
- return unless defined($v) && $v == 2;
+ return if $self->version < 2;
my $cur = $self->{-max_git_epoch};
my $changed = git($self)->alternates_changed;
if (!defined($cur) || $changed) {
require PublicInbox::Msgmap;
_cleanup_later($self);
my $dir = $self->{inboxdir};
- if (($self->{version} || 1) >= 2) {
+ if ($self->version >= 2) {
PublicInbox::Msgmap->new_file("$dir/msgmap.sqlite3");
} else {
PublicInbox::Msgmap->new($dir);
# nntp://news.example.com/alt.example
push @m, $u;
}
- my %seen = map { $_ => 1 } @urls;
- foreach my $u (@m) {
- next if $seen{$u};
- $seen{$u} = 1;
- push @urls, $u;
- }
+
+ # List::Util::uniq requires Perl 5.26+, maybe we
+ # can use it by 2030 or so
+ my %seen;
+ @urls = grep { !$seen{$_}++ } (@urls, @m);
}
\@urls;
};