gitweb: Faster return from git_get_preceding_references if possible
authorJakub Narebski <jnareb@gmail.com>
Thu, 24 Aug 2006 17:39:32 +0000 (19:39 +0200)
committerJunio C Hamano <junkio@cox.net>
Sat, 26 Aug 2006 02:39:55 +0000 (19:39 -0700)
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>
gitweb/gitweb.perl

index b964302a5aa9a24cedc39bb3ffcabb9bc91b6f50..01452d2c747bb29540d512ece6887c91b2ef040e 100755 (executable)
@@ -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;
 }
 
 ## ----------------------------------------------------------------------