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>
Jakub Narebski committed
Aug 24, 2006 at 19:39 UTC
3066c359c63d1dc32db5147ebf015fe9bba4c5bb
1 file changed
+2
-3
gitweb/gitweb.perl
+2
-3
@@ -789,16 +789,15 @@ sub git_get_preceding_references {
789
or return undef;
790
791
my @reflist;
792
- my $firstref;
792
793
foreach my $commit (@commits) {
794
foreach my $ref (@{$refs->{$commit}}) {
796
- $firstref = $ref unless $firstref;
795
+ return $ref unless wantarray;
796
push @reflist, $ref;
797
}
798
}
799
801
- return wantarray ? @reflist : $firstref;
800
+ return @reflist;
801
}
802
803
## ----------------------------------------------------------------------