Re: [PATCH 2/2] gitweb: Make git_get_refs_list do work of git_get_references
- From
Jakub Narebski <jnareb@gmail.com>
- Date
- Sep 20, 2006, 22:40 UTC
- Message-ID
- <200609210040.52886.jnareb@gmail.com>
- In-Reply-To
- <7veju6h0et.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
Show 24 quoted lines
> Jakub Narebski wrote:
>> + if (! $4) { # unpeeled, direct reference
>> + push @refs, { hash => $1, name => $3 }; # without type
>> + } elsif ($3 eq $refs[-1]{'name'}) {
>> + # most likely a tag is followed by its peeled
>> + # (deref) one, and when that happens we know the
>> + # previous one was of type 'tag'.
>> + $refs[-1]{'type'} = "tag";
>> + }
>>...
>> - return \@reflist;
>> + return (\@reflist, \%refs);
>
> You are maintaining reflist (an array of hashrefs each element
> of which describes name, type, hash and other parse_ref()
> information for the ref) and refs (a hash that maps from name to
> hash) separatly. I wonder if this really has the performance
> advantage over just compute and return reflist from here and
> have the callers who need the mapping to derive it from the list
> (i.e.
>
> my ($reflist) = git_get_refs_list();
> my %refs = map { $_->{name} => $_->{hash} } @$reflist;
> ).The %refs hash contain also map from peeled (dereferenced) object to ref name. The information about derefs is not present in @reflist. So the answer is that you can't derive %refs from @reflist.
-- Jakub Narebski ShadeHawk on #git Poland