From: Jakub Narebski Date: Thu, 24 Aug 2006 17:39:32 +0000 (+0200) Subject: gitweb: Faster return from git_get_preceding_references if possible X-Git-Tag: v1.4.3-rc1~168^2~21 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3066c359c63d1dc32db5147ebf015fe9bba4c5bb;p=git.git gitweb: Faster return from git_get_preceding_references if possible Return on first ref found when git_get_preceding_references is called in scalar context Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index b964302a5..01452d2c7 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; } ## ----------------------------------------------------------------------