If we already have a hash function for an object, it might make sense
to
just reuse that (if only for people like me, who get easily confused
otherwise). Pointers might actually have less useful bits since they
could be clustered together or are aligned on certain addresses, making
some of the bits all equal.
Hmm. Perhaps that's so, but perfect is perfect, no? My understanding is
that the integer hash function (multiplying by a prime close to the golden
ratio times the maximum value for the bit width) is supposed to move the
bits around well so that modulus won't lose all that perfection. Since
we're already storing the previously-computed hash value, it's similarly
cheap to just fetch it (one load vs one multiply). Either way, we can
fiddle the hash functions later when we see the manifest reality of
collision likelihoods on real data.
Thanks,
Roland