]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* hashtable.c (ht_expand): Avoid calculating rehash for the common
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 22 Aug 2003 22:29:17 +0000 (22:29 +0000)
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 22 Aug 2003 22:29:17 +0000 (22:29 +0000)
case that the first probe hits an empty hash table slot.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70706 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/hashtable.c

index 3dd61eb896a153279be5f4c8f803331790448aab..f97afe2b005c8ea5442a66cb217eb4109478b63f 100644 (file)
@@ -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.
index 41551394f8aa6dc35be116b4d32f132d33c6e226..58f19d055fc21c402146d581b584dcdfd639a47f 100644 (file)
@@ -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);