[augeas-devel] [PATCH 3 of 6] Suppress assert of hash_verify
David Lutterkort
dlutter at redhat.com
Tue May 6 01:12:22 UTC 2008
# HG changeset patch
# User David Lutterkort <dlutter at redhat.com>
# Date 1210036189 25200
# Node ID 3a8d71e509488b78bc30ae943bd14044c1805b50
# Parent 3f3b57d37d78c8bb0f99483b2cec991533fad761
Suppress assert of hash_verify
Doing the assert(hash_verify(hash)) at various places in hash.c is very
expensive and slows things down considerably when assertions are turned
on.
Rather than turning assertions off globally, only do the hash_verify
asserts when they are explicitly requested by defining HASH_DEBUG_VERIFY
diff -r 3f3b57d37d78 -r 3a8d71e50948 src/hash.c
--- a/src/hash.c Mon May 05 18:09:28 2008 -0700
+++ b/src/hash.c Mon May 05 18:09:49 2008 -0700
@@ -199,7 +199,9 @@ static void grow_table(hash_t *hash)
hash->lowmark *= 2;
hash->highmark *= 2;
}
+#ifdef HASH_DEBUG_VERIFY
assert (hash_verify(hash));
+#endif
}
/*
@@ -260,7 +262,9 @@ static void shrink_table(hash_t *hash)
hash->nchains = nchains;
hash->lowmark /= 2;
hash->highmark /= 2;
+#ifdef HASH_DEBUG_VERIFY
assert (hash_verify(hash));
+#endif
}
@@ -319,7 +323,9 @@ hash_t *hash_create(hashcount_t maxcount
hash->mask = INIT_MASK;
hash->dynamic = 1; /* 7 */
clear_table(hash); /* 8 */
+#ifdef HASH_DEBUG_VERIFY
assert (hash_verify(hash));
+#endif
return hash;
}
free(hash);
@@ -418,8 +424,9 @@ hash_t *hash_init(hash_t *hash, hashcoun
hash->mask = compute_mask(nchains); /* 4 */
clear_table(hash); /* 5 */
+#ifdef HASH_DEBUG_VERIFY
assert (hash_verify(hash));
-
+#endif
return hash;
}
@@ -540,7 +547,9 @@ void hash_insert(hash_t *hash, hnode_t *
hash->table[chain] = node;
hash->nodecount++;
+#ifdef HASH_DEBUG_VERIFY
assert (hash_verify(hash));
+#endif
}
/*
@@ -618,7 +627,9 @@ hnode_t *hash_delete(hash_t *hash, hnode
}
hash->nodecount--;
+#ifdef HASH_DEBUG_VERIFY
assert (hash_verify(hash));
+#endif
node->next = NULL; /* 6 */
return node;
@@ -667,7 +678,9 @@ hnode_t *hash_scan_delete(hash_t *hash,
}
hash->nodecount--;
+#ifdef HASH_DEBUG_VERIFY
assert (hash_verify(hash));
+#endif
node->next = NULL;
return node;
More information about the augeas-devel
mailing list