This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch to change hashtab.h hashval_t to size_t


DJ Delorie <dj@redhat.com> writes:

> > Your points are certainly valid.  However I'm still concerned that the
> > truncation may result in poor hash values.  If we're not going to
> > address this in libiberty, then perhaps we should address it in gcc
> > itself like you said.
> 
> hashtab.c almost always does "hash % size" so on most platforms,
> pointers would be poor choices for hash values unless you shift off
> the lowest (alignment) bits.

Actually, 'size' is prime, so it doesn't matter if the hash value is
always a multiple of some number.

There's nothing particularly wrong with what hashtab.c already does:

/* Returns a hash code for P.  */

static hashval_t
hash_pointer (p)
     const PTR p;
{
  return (hashval_t) ((long)p >> 3);
}

-- 
- Geoffrey Keating <geoffk@geoffk.org>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]