[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jgit-dev] Improving ObjectIdSubclassMap performance
|
On Wed, Mar 9, 2011 at 12:50, Johannes Schindelin
<Johannes.Schindelin@xxxxxx> wrote:
> My guess is that the hash calculation makes for the overhead. If that is
> the case, you might want to use several parts of the SHA-1 as
> different hashes (interpreting the 20-byte as 5 32-bit integers gives you
> five hash functions for the price of one), because the SHA-1 has been
> calculated anyway.
That's what we do already. SHA-1s are already stored as 5 primitive
ints in Java, by treating the raw 20 bytes as 5 network byte-order
integers and converting them to primitive integer values.
The current table maps that onto a slot in the hashtable with:
(id.w1 >>> 1) % obj_hash.length
Which could be faster, the table length is currently always a power of
2. So we could rewrite this as:
id.w1 & table_mask
Where table_mask is just:
table_mask = obj_hash.length - 1.
:-)
--
Shawn.