From 4ae2e3e9225dbd7b2eb6d08577b045bd0a0d017f Mon Sep 17 00:00:00 2001 From: Roger Sayle <roger@eyesopen.com> Date: Fri, 22 Aug 2003 22:29:17 +0000 Subject: [PATCH] hashtable.c (ht_expand): Avoid calculating rehash for the common case that the first probe hits an empty... * hashtable.c (ht_expand): Avoid calculating rehash for the common case that the first probe hits an empty hash table slot. From-SVN: r70706 --- gcc/ChangeLog | 5 +++++ gcc/hashtable.c | 13 ++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3dd61eb896a1..f97afe2b005c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2003-08-22 Roger Sayle <roger@eyesopen.com> + + * hashtable.c (ht_expand): Avoid calculating rehash for the common + case that the first probe hits an empty hash table slot. + 2003-08-22 Mark Mitchell <mark@codesourcery.com> * config/ia64/hpux.h (SUPPORTS_INIT_PRIORITY): Define to 0. diff --git a/gcc/hashtable.c b/gcc/hashtable.c index 41551394f8aa..58f19d055fc2 100644 --- a/gcc/hashtable.c +++ b/gcc/hashtable.c @@ -184,19 +184,18 @@ ht_expand (hash_table *table) unsigned int index, hash, hash2; hash = (*p)->hash_value; - hash2 = ((hash * 17) & sizemask) | 1; index = hash & sizemask; - for (;;) + if (nentries[index]) { - if (! nentries[index]) + hash2 = ((hash * 17) & sizemask) | 1; + do { - nentries[index] = *p; - break; + index = (index + hash2) & sizemask; } - - index = (index + hash2) & sizemask; + while (nentries[index]); } + nentries[index] = *p; } while (++p < limit); -- GitLab