Re: [PATCH 1/8] fetch.c: Remove useless lookup_object_type() call in process()
- From
Sergey Vlasov <vsu@altlinux.ru>
- Date
- Sep 22, 2005, 08:50 UTC
- Message-ID
- <20050922085009.GC20944@master.mivlgu.local>
- In-Reply-To
- <7v3bnyurw6.fsf@assigned-by-dhcp.cox.net>
On Wed, Sep 21, 2005 at 12:45:13PM -0700, Junio C Hamano wrote:
Show 10 quoted lines
> Sergey Vlasov <vsu@altlinux.ru> writes: > > > In all places where process() is called except the one in pull() (which > > is executed only once) the pointer to the object is already available, > > so pass it as the argument to process() instead of sha1 and avoid an > > unneeded call to lookup_object_type(). > > Agreed, except we probably would want to pass the expected type > to process() so that we can make sure the object is of that type, > perhaps?
This is not needed - all parse_*_buffer() functions, which fill in pointers to referenced objects, specify required types themselves by using lookup_commit(), lookup_tree(), etc.; even parse_tag_buffer() uses lookup_object_type().
The only way to get a "struct object" with an unspecified type is by calling lookup_unknown_object() (or lookup_object_type() with NULL type) - grep shows than nothing in GIT does this, except the pull() function in fetch.c (which obviously does not know type of the object to be fetched in advance).