summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6abe0f0)
raw | patch | inline | side by side (parent: 6abe0f0)
author | Junio C Hamano <gitster@pobox.com> | |
Wed, 4 Jul 2007 05:10:42 +0000 (22:10 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 7 Jul 2007 21:18:13 +0000 (14:18 -0700) |
If repeated calls to git_get_project_owner() are made, we would have read the
same file over and over again.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
same file over and over again.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitweb/gitweb.perl | patch | blob | history |
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index dbfb0441a6a59e6fe069a515a2d293f4d860e143..d5b8812a121e4cd7ec02c2d17412f361134a01bf 100755 (executable)
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
return @list;
}
-sub git_get_project_owner {
- my $project = shift;
- my $owner;
+our $gitweb_project_owner = undef;
+sub git_get_project_list_from_file {
- return undef unless $project;
+ return if (defined $gitweb_project_owner);
+ $gitweb_project_owner = {};
# read from file (url-encoded):
# 'git%2Fgit.git Linus+Torvalds'
# 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
my ($pr, $ow) = split ' ', $line;
$pr = unescape($pr);
$ow = unescape($ow);
- if ($pr eq $project) {
- $owner = to_utf8($ow);
- last;
- }
+ $gitweb_project_owner->{$pr} = to_utf8($ow);
}
close $fd;
}
+}
+
+sub git_get_project_owner {
+ my $project = shift;
+ my $owner;
+
+ return undef unless $project;
+
+ if (!defined $gitweb_project_owner) {
+ git_get_project_list_from_file();
+ }
+
+ if (exists $gitweb_project_owner->{$project}) {
+ $owner = $gitweb_project_owner->{$project};
+ }
if (!defined $owner) {
$owner = get_file_owner("$projectroot/$project");
}