From f77ed96c7bc56ceff1efa81a78fc9a02006e844f Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Mon, 17 Mar 2003 18:01:07 +0000 Subject: [PATCH] merge from gcc --- include/ChangeLog | 4 ++++ include/hashtab.h | 1 + libiberty/ChangeLog | 5 +++++ libiberty/hashtab.c | 23 +++++++++++++++++++---- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/include/ChangeLog b/include/ChangeLog index c98e61e4360..64e73c62454 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +2003-03-17 Jan Hubicka + + * hashtab.h (htab_traverse_noresize): Declare. + 2003-02-27 Kaveh R. Ghazi * libiberty.h: Document return value of physmem routines. diff --git a/include/hashtab.h b/include/hashtab.h index 4995a9a10e0..7acb5eb2859 100644 --- a/include/hashtab.h +++ b/include/hashtab.h @@ -168,6 +168,7 @@ extern void htab_clear_slot PARAMS ((htab_t, void **)); extern void htab_remove_elt PARAMS ((htab_t, void *)); extern void htab_traverse PARAMS ((htab_t, htab_trav, void *)); +extern void htab_traverse_noresize PARAMS ((htab_t, htab_trav, void *)); extern size_t htab_size PARAMS ((htab_t)); extern size_t htab_elements PARAMS ((htab_t)); diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index a45e537f4e2..667d93b1bda 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,8 @@ +2003-17-03 Jan Hubicka + + * hashtab.c (htab_traverse_noresize): Break out from ... + * hashtab.c (htab_traverse): ... here. + 2003-12-03 Jan Hubicka * hashtab.c (htab_expand): Fix warning. diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c index ebaa43b2c50..2f8dfd6c581 100644 --- a/libiberty/hashtab.c +++ b/libiberty/hashtab.c @@ -603,7 +603,7 @@ htab_clear_slot (htab, slot) argument. */ void -htab_traverse (htab, callback, info) +htab_traverse_noresize (htab, callback, info) htab_t htab; htab_trav callback; PTR info; @@ -611,9 +611,6 @@ htab_traverse (htab, callback, info) PTR *slot; PTR *limit; - if ((htab->n_elements - htab->n_deleted) * 8 < htab->size) - htab_expand (htab); - slot = htab->entries; limit = slot + htab->size; @@ -628,6 +625,24 @@ htab_traverse (htab, callback, info) while (++slot < limit); } +/* Like htab_traverse_noresize, but does resize the table when it is + too empty to improve effectivity of subsequent calls. */ + +void +htab_traverse (htab, callback, info) + htab_t htab; + htab_trav callback; + PTR info; +{ + PTR *slot; + PTR *limit; + + if ((htab->n_elements - htab->n_deleted) * 8 < htab->size) + htab_expand (htab); + + htab_traverse_noresize (htab, callback, info); +} + /* Return the current size of given hash table. */ size_t -- 2.30.2