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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Jakub Narebski <jnareb@xxxxxxxxx>
---
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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]