diff options
author | DJ Delorie <dj@redhat.com> | 2003-03-12 15:08:02 +0000 |
---|---|---|
committer | DJ Delorie <dj@redhat.com> | 2003-03-12 15:08:02 +0000 |
commit | c4d8feb262fa437232fb144da11b9f449d3b7715 (patch) | |
tree | e4ce4eb4402b6cb8b02b81673b00e25e7b68f53b /libiberty/hashtab.c | |
parent | 64fb18397420d25e0ef96ab34198adb2ee890885 (diff) | |
download | gdb-c4d8feb262fa437232fb144da11b9f449d3b7715.zip gdb-c4d8feb262fa437232fb144da11b9f449d3b7715.tar.gz gdb-c4d8feb262fa437232fb144da11b9f449d3b7715.tar.bz2 |
merge from gcc
Diffstat (limited to 'libiberty/hashtab.c')
-rw-r--r-- | libiberty/hashtab.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c index 0429936..a0cb5a7 100644 --- a/libiberty/hashtab.c +++ b/libiberty/hashtab.c @@ -373,7 +373,14 @@ htab_expand (htab) oentries = htab->entries; olimit = oentries + htab->size; - nsize = higher_prime_number (htab->size * 2); + /* Resize only when table after removal of unused elements is either + too full or too empty. */ + if ((htab->n_elements - htab->n_deleted) * 2 > htab->size + || (htab->n_elements - htab->n_deleted) * 8 < htab->size + && htab->size > 32) + nsize = higher_prime_number ((htab->n_elements - htab->n_deleted) * 2); + else + nsize = htab->size; if (htab->alloc_with_arg_f != NULL) nentries = (PTR *) (*htab->alloc_with_arg_f) (htab->alloc_arg, nsize, @@ -601,8 +608,14 @@ htab_traverse (htab, callback, info) htab_trav callback; PTR info; { - PTR *slot = htab->entries; - PTR *limit = slot + htab->size; + PTR *slot; + PTR *limit; + + if ((htab->n_elements - htab->n_deleted) * 8 < htab->size) + htab_expand (htab); + + slot = htab->entries; + limit = slot + htab->size; do { |