[Top][All Lists]

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

Re: hash resizing bug

From: Ben Pfaff
Subject: Re: hash resizing bug
Date: Thu, 18 Jun 2009 11:34:55 -0700
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Eric Blake <address@hidden> writes:

>  static size_t
>  raw_hasher (const void *data, size_t n)
>  {
> -  return (size_t) data % n;
> +  /* When hashing unique pointers, it is often the case that they were
> +     generated by malloc and thus have the property that the low-order
> +     bits are 0.  As this tends to give poorer performance with small
> +     tables, we rotate the pointer value before performing division,
> +     in an attempt to improve hash quality.  */
> +  size_t val = data;

I would expect this initialization of an integer from a pointer
without a cast to provoke a warning.
Ben Pfaff 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]