[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[augeas-devel] augeas: master - * src/hash.c (hash_free_nodes): simplify and accelerate



Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=6672ea305de0f216d821d0f81b53a9d9649f8a42
Commit:        6672ea305de0f216d821d0f81b53a9d9649f8a42
Parent:        70ae697121f6465a2d95f7b9eb33dacc98da8c17
Author:        David Lutterkort <lutter redhat com>
AuthorDate:    Fri Mar 27 15:59:48 2009 -0700
Committer:     David Lutterkort <lutter redhat com>
CommitterDate: Fri Mar 27 15:59:48 2009 -0700

* src/hash.c (hash_free_nodes): simplify and accelerate

Reduces time to typecheck grub.aug from 9.8s to 8.5s on my machine.
---
 src/hash.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/hash.c b/src/hash.c
index f35a9d2..892532f 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -357,12 +357,17 @@ void hash_set_allocator(hash_t *hash, hnode_alloc_t al,
 
 void hash_free_nodes(hash_t *hash)
 {
-    hscan_t hs;
-    hnode_t *node;
-    hash_scan_begin(&hs, hash);
-    while ((node = hash_scan_next(&hs))) {
-	hash_scan_delete(hash, node);
-	hash->freenode(node, hash->context);
+    hnode_t *node, *next;
+    hash_val_t chain;
+
+    for (chain = 0; chain < hash->nchains; chain ++) {
+      node = hash->table[chain];
+      while (node != NULL) {
+        next = node->next;
+        hash->freenode(node, hash->context);
+        node = next;
+      }
+      hash->table[chain] = NULL;
     }
     hash->nodecount = 0;
     clear_table(hash);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]