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

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

 



On Sunday 20 August 2006 18:09, Johannes Schindelin wrote:
Hi,

> Most notably, it adds an object hash map structure to the library.

Aside from the given command of this thread, this is interesting
(even more interesting would be a persistent cache for arbitrary object data).
As this could be used in other contexts, some general comments:

> +static unsigned int hash_index(struct hash_map *hash, const char *sha1)
> +{
> +	unsigned int index = *(unsigned int *)sha1;

If you have the same SHA1, stored at different addresses, you get different
indexes for the same SHA1. Index probably should be calculated from the
SHA1 string.

> +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.

Josef
-
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]