From 9b8ebfddd479bfeda479d2842587269dc9a21752 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 26 Sep 2022 10:17:15 +0000 Subject: git: reduce early bare-bones memory use The {-git_path} cache can rely on auto-vivification, and {alt_st} may not be needed for short-lived repos. So don't populate those fields until they're needed, since we can expect to handle thousands of git repos, too. --- lib/PublicInbox/Git.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/Git.pm') diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index b2ae75c8..9140caea 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -66,7 +66,7 @@ sub new { $git_dir =~ tr!/!/!s; $git_dir =~ s!/*\z!!s; # may contain {-tmp} field for File::Temp::Dir - bless { git_dir => $git_dir, alt_st => '', -git_path => {} }, $class + bless { git_dir => $git_dir }, $class } sub git_path ($$) { @@ -90,7 +90,7 @@ sub alternates_changed { # can't rely on 'q' on some 32-bit builds, but `d' works my $st = pack('dd', $st[10], $st[7]); # 10: ctime, 7: size - return 0 if $self->{alt_st} eq $st; + return 0 if ($self->{alt_st} // '') eq $st; $self->{alt_st} = $st; # always a true value } -- cgit v1.2.3-24-ge0c7