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 <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
maint
Jakub Narebski 2006-08-24 19:39:32 +02:00 committed by Junio C Hamano
parent 470b96d483
commit 3066c359c6
1 changed files with 2 additions and 3 deletions

View File

@ -789,16 +789,15 @@ sub git_get_preceding_references {
or return undef; or return undef;


my @reflist; my @reflist;
my $firstref;


foreach my $commit (@commits) { foreach my $commit (@commits) {
foreach my $ref (@{$refs->{$commit}}) { foreach my $ref (@{$refs->{$commit}}) {
$firstref = $ref unless $firstref; return $ref unless wantarray;
push @reflist, $ref; push @reflist, $ref;
} }
} }


return wantarray ? @reflist : $firstref; return @reflist;
} }


## ---------------------------------------------------------------------- ## ----------------------------------------------------------------------