]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
dedupe inbox names, coderepo nicks + git dirs
authorEric Wong <e@80x24.org>
Mon, 4 Mar 2024 21:10:46 +0000 (21:10 +0000)
committerEric Wong <e@80x24.org>
Fri, 8 Mar 2024 20:49:48 +0000 (20:49 +0000)
Inbox names, coderepo nicks, git_dir values are used heavily
as hash keys by the read-only coderepo WWW pieces.

Relying on CoW for mutable scalars on newer Perl doesn't work
well since CoW for those scalars are limited to 256 CoW references
and blow past that number when mapping thousands of coderepos
and inboxes to each other.  Instead, make the hash key up-front
and get the resulting string to point directly to the pointer
used by the hash key.

lib/PublicInbox/Config.pm
lib/PublicInbox/Git.pm

index 607197f61583cc264605d91b4f48ac529638aca6..d630061067c5e8ac7964da01b8a843d5c9fce0a8 100644 (file)
@@ -379,7 +379,8 @@ sub fill_coderepo {
                $git->{cgit_url} = $cgits = _array($cgits);
                $self->{"$pfx.cgiturl"} = $cgits;
        }
-       $git->{nick} = $nick;
+       my %dedupe = ($nick => undef);
+       ($git->{nick}) = keys %dedupe;
        $git;
 }
 
@@ -486,7 +487,8 @@ sub _fill_ibx {
        }
 
        return unless valid_foo_name($name, 'publicinbox');
-       $ibx->{name} = $name;
+       my %dedupe = ($name => undef);
+       ($ibx->{name}) = keys %dedupe; # used as a key everywhere
        $ibx->{-pi_cfg} = $self;
        $ibx = PublicInbox::Inbox->new($ibx);
        foreach (@{$ibx->{address}}) {
index f125b0291934af42c5677293f22c7f2140e926aa..af12f14184fbe26d9506a8fc911c22c8335d73e2 100644 (file)
@@ -96,7 +96,8 @@ sub new {
        $git_dir =~ tr!/!/!s;
        chop $git_dir;
        # may contain {-tmp} field for File::Temp::Dir
-       bless { git_dir => $git_dir }, $class
+       my %dedupe = ($git_dir => undef);
+       bless { git_dir => (keys %dedupe)[0] }, $class
 }
 
 sub git_path ($$) {