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>
This commit is contained in:
Jakub Narebski 2006-08-24 19:39:32 +02:00 committed by Junio C Hamano
parent 470b96d483
commit 3066c359c6

View File

@ -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;
}
## ----------------------------------------------------------------------