summaryrefslogtreecommitdiffstats
path: root/libiberty/hashtab.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2006-07-27 17:10:07 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2006-07-27 17:10:07 +0000
commit44109858d6da1226c5a461ded62eb043c311f8f3 (patch)
tree14266ba8c54052b56789938ae15882d061451a22 /libiberty/hashtab.c
parentb0d535b8b41f804bb2651c279ce61f6b99ea781e (diff)
downloadppe42-gcc-44109858d6da1226c5a461ded62eb043c311f8f3.tar.gz
ppe42-gcc-44109858d6da1226c5a461ded62eb043c311f8f3.zip
PR rtl-optimization/28071
* hashtab.c (htab_empty): Clear out n_deleted/n_elements; downsize the hashtable. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@115779 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libiberty/hashtab.c')
-rw-r--r--libiberty/hashtab.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c
index a5671a0a768..bf34a6d297e 100644
--- a/libiberty/hashtab.c
+++ b/libiberty/hashtab.c
@@ -421,7 +421,28 @@ htab_empty (htab_t htab)
if (entries[i] != HTAB_EMPTY_ENTRY && entries[i] != HTAB_DELETED_ENTRY)
(*htab->del_f) (entries[i]);
- memset (entries, 0, size * sizeof (PTR));
+ /* Instead of clearing megabyte, downsize the table. */
+ if (size > 1024*1024 / sizeof (PTR))
+ {
+ int nindex = higher_prime_index (1024 / sizeof (PTR));
+ int nsize = prime_tab[nindex].prime;
+
+ if (htab->free_f != NULL)
+ (*htab->free_f) (htab->entries);
+ else if (htab->free_with_arg_f != NULL)
+ (*htab->free_with_arg_f) (htab->alloc_arg, htab->entries);
+ if (htab->alloc_with_arg_f != NULL)
+ htab->entries = (PTR *) (*htab->alloc_with_arg_f) (htab->alloc_arg, nsize,
+ sizeof (PTR *));
+ else
+ htab->entries = (PTR *) (*htab->alloc_f) (nsize, sizeof (PTR *));
+ htab->size = nsize;
+ htab->size_prime_index = nindex;
+ }
+ else
+ memset (entries, 0, size * sizeof (PTR));
+ htab->n_deleted = 0;
+ htab->n_elements = 0;
}
/* Similar to htab_find_slot, but without several unwanted side effects:
OpenPOWER on IntegriCloud