Re: Libgit2 on the Summer of Code
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 2, 2010, 18:42 UTC
- Message-ID
- <7vvda1cm42.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <AANLkTilE7UI3zg180U9GCB6DsByu3B9pwlG6xIyR8uiG@mail.gmail.com>
Alex Riesen <raa.lkml@gmail.com> writes:
Show 15 quoted lines
> On Thu, May 27, 2010 at 20:05, Shawn O. Pearce <spearce@spearce.org> wrote: >> Ilari Liusvaara <ilari.liusvaara@elisanet.fi> wrote: >>> * Where algorithm in git_revpool_table__hash() is from? Since it appears to >>> hash binary object IDs, wouldn't just simple sum/xor over words be sufficient >>> (all SHA-1 output bits are very nearly independent). Or do you need to be >>> compatible with some other implementation (doesn't appear so, because hash >>> is computed differently depending on endianess)? >> >> If you need a hash value for a SHA-1, why not just cast the unsigned >> char* to unsigned int* and load the first int as the hash code? >> The output of SHA-1 is pretty evenly distributed, using the first >> few bytes as an int should yield a sufficient distribution throughout >> the hashtable. > > Just make sure the SHA1 data are properly aligned for your platform
Also I'd prefer to see the code watch out for reproducibility across platforms with different endianness and integer size.