Subject: [PATCH 7] gitweb: Faster return from git_get_preceding_references if possible

From: Jakub Narebski <[email-masked]>
Date: Thu, 24 Aug 2006 19:39:32 +0200

Return on first ref found when git_get_preceding_references
is called in scalar context

Signed-off-by: Jakub Narebski <[email-masked]>
---
Jakub Narebski wrote:
> Actually, the two following patches adresses this, not this patch...

The two following this patch...

 gitweb/gitweb.perl |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 2d3776a..a068a81 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -789,16 +789,15 @@ sub git_get_preceding_references {
 		or return undef;
 
 	my @reflist;
-	my $firstref;
 
 	foreach my $commit (@commits) {
 		foreach my $ref (@{$refs->{$commit}}) {
-			$firstref = $ref unless $firstref;
+			return $ref unless wantarray;
 			push @reflist, $ref;
 		}
 	}
 
-	return wantarray ? @reflist : $firstref;
+	return @reflist;
 }
 
 ## ----------------------------------------------------------------------
-- 
1.4.1.1