http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50165

--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-08-24 
10:37:18 UTC ---
Btw, as ->len includes the trailing zero, the new hash function hashes in
a zero and the memcmp compares one byte unnecessarily.  To make the transform
1:1 it would be

static inline hashval_t
hash_string_slot_node (const void *p)
{
  const struct string_slot *ds = (const struct string_slot *) p;
  hashval_t r = 0;
  int i;

  for (i = 0; i < ds->len - 1; i++)
     r = r * 67 + (unsigned char)ds->s[i] - 113;
  return r;
}

static inline int
eq_string_slot_node (const void *p1, const void *p2)
{
  const struct string_slot *ds1 = (const struct string_slot *) p1;
  const struct string_slot *ds2 = (const struct string_slot *) p2;

  if (ds1->len == ds2->len)
    return strncmp (ds1->s, ds2->s, ds1->len - 1) == 0;

  return 0;
}

which, if it works fine, would be ok with me.

Reply via email to