summaryrefslogtreecommitdiff
path: root/gcc/objc/hash.c
diff options
context:
space:
mode:
authorkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>1997-02-03 00:42:48 +0000
committerkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>1997-02-03 00:42:48 +0000
commit9efb5785e08713da34f7741beb091acca654e3a8 (patch)
tree845c31cfe2b7f3e331d782706f0d8c0ce1e43d80 /gcc/objc/hash.c
parent62b0af4252ace8ca230f5b7fed12ed3b59da95b2 (diff)
downloadgcc-9efb5785e08713da34f7741beb091acca654e3a8.tar.gz
(hash_delete): Step through the hash nodes versus using hash_next to
increase efficiency. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@13593 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/objc/hash.c')
-rw-r--r--gcc/objc/hash.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/gcc/objc/hash.c b/gcc/objc/hash.c
index 4a1dca989d6..7534330fa1c 100644
--- a/gcc/objc/hash.c
+++ b/gcc/objc/hash.c
@@ -1,5 +1,5 @@
/* Hash tables for Objective C internal structures
- Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -80,11 +80,24 @@ void
hash_delete (cache_ptr cache)
{
node_ptr node;
-
+ node_ptr next_node;
+ unsigned int i;
/* Purge all key/value pairs from the table. */
- while ((node = hash_next (cache, NULL)))
- hash_remove (cache, node->key);
+ /* Step through the nodes one by one and remove every node WITHOUT
+ using hash_next. this makes hash_delete much more efficient. */
+ for (i = 0;i < cache->size;i++) {
+ if ((node = cache->node_table[i])) {
+ /* an entry in the hash table has been found, now step through the
+ nodes next in the list and free them. */
+ while ((next_node = node->next)) {
+ hash_remove (cache,node->key);
+ node = next_node;
+ }
+
+ hash_remove (cache,node->key);
+ }
+ }
/* Release the array of nodes and the cache itself. */
objc_free(cache->node_table);
@@ -242,7 +255,7 @@ hash_value_for_key (cache_ptr cache, const void *key)
do {
if ((*cache->compare_func)(node->key, key)) {
retval = node->value;
- break;
+ break;
} else
node = node->next;
} while (!retval && node);