From 3066c359c63d1dc32db5147ebf015fe9bba4c5bb Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Thu, 24 Aug 2006 19:39:32 +0200 Subject: [PATCH] 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 --- gitweb/gitweb.perl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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; } ## ---------------------------------------------------------------------- -- 2.26.2