Re: Object hash (was: Re: [ANNOUNCE] git-rev-size: calculate sizes of repository)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Sun, 20 Aug 2006, Josef Weidendorfer wrote:

> On Sunday 20 August 2006 18:51, Johannes Schindelin wrote:
> 
> > > > +void hash_put(struct hash_map *hash, struct object *obj)
> > > > +{
> > > > +	if (++hash->nr > hash->alloc / 2)
> > > > +		grow_hash(hash);
> > > 
> > > If you insert the same object multiple times, hash->nr will get too big.
> > 
> > First, you cannot put the same object multiple times. That is not what a  
> > hash does (at least in this case): it stores unique objects (identified by 
> > their sha1 in this case).
> 
> I put it the wrong way; I should have said "if you call hash_put() multiple
> times with the same object". You get the same index, and nothing should
> change. However, you still increment hash->nr, but this error is not really
> important as you correct it in grow_hash().

Talk about unintended side effects ;-)

Ciao,
Dscho

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]