Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Miklos Vajna <vmiklos@frugalware.org>
Cc: git@vger.kernel.org, Petr Baudis <pasky@suse.cz>,
	Jakub Narebski <jnareb@gmail.com>,
	Luben Tuikov <ltuikov@yahoo.com>
Subject: Re: [PATCH] gitweb: prefer git_get_project_owner() over get_file_owner()
Date: Tue, 03 Jul 2007 22:10:42 -0700	[thread overview]
Message-ID: <7vzm2ckb3h.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: 20070703221122.GI32766@genesis.frugalware.org

Miklos Vajna <vmiklos@frugalware.org> writes:

> This way if $projects_list exists, it'll be used, otherwise get_file_owner()
> will be used as before.
>
> Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>

The patch looks good to me.

HOWEVER.

It strikes me that repeated call to git_get_project_owner()
would be way too inefficient.  Not caller's fault.

How about doing something like this on top of your patch?

 gitweb/gitweb.perl |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index dbfb044..f114585 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1465,12 +1465,12 @@ sub git_get_projects_list {
 	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'
@@ -1482,13 +1482,25 @@ sub git_get_project_owner {
 			my ($pr, $ow) = split ' ', $line;
 			$pr = unescape($pr);
 			$ow = unescape($ow);
-			if ($pr eq $project) {
-				$owner = to_utf8($ow);
-				last;
-			}
+			$gitweb_project_owner->{$project} = 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");
 	}

  reply	other threads:[~2007-07-04  5:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <11834862893846-git-send-email-vmiklos@frugalware.org>
     [not found] ` <11834866911868-git-send-email-vmiklos@frugalware.org>
2007-07-03 22:11   ` [PATCH] gitweb: prefer git_get_project_owner() over get_file_owner() Miklos Vajna
2007-07-04  5:10     ` Junio C Hamano [this message]
2007-07-07 19:05       ` Luben Tuikov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vzm2ckb3h.fsf@assigned-by-dhcp.cox.net \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jnareb@gmail.com \
    --cc=ltuikov@yahoo.com \
    --cc=pasky@suse.cz \
    --cc=vmiklos@frugalware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox