about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2024-03-04 21:10:46 +0000
committerEric Wong <e@80x24.org>2024-03-08 20:49:48 +0000
commit84ed7ec1c88721c25955d61f5904250fb07d7af6 (patch)
treedeb5497deeca34912bcfaaebe941e4aab392dbaf /lib
parente7c8ab553ee21acf9c9ac0a9180aa76080716290 (diff)
downloadpublic-inbox-84ed7ec1c88721c25955d61f5904250fb07d7af6.tar.gz
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/Config.pm6
-rw-r--r--lib/PublicInbox/Git.pm3
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index 607197f6..d6300610 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -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}}) {
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index f125b029..af12f141 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -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 ($$) {