aboutsummaryrefslogtreecommitdiff
path: root/src/ckh.c
diff options
context:
space:
mode:
authorJason Evans <je@fb.com>2012-02-10 20:22:09 -0800
committerJason Evans <je@fb.com>2012-02-10 20:22:09 -0800
commit7372b15a31c63ac5cb9ed8aeabc2a0a3c005e8bf (patch)
tree9b0f1156e6aa61f50a01c90b72fdaefeabe414a8 /src/ckh.c
parentb3bd885090230cc28add77c399b4ed440b760ca3 (diff)
downloadjemalloc-7372b15a31c63ac5cb9ed8aeabc2a0a3c005e8bf.tar.gz
Reduce cpp conditional logic complexity.
Convert configuration-related cpp conditional logic to use static constant variables, e.g.: #ifdef JEMALLOC_DEBUG [...] #endif becomes: if (config_debug) { [...] } The advantage is clearer, more concise code. The main disadvantage is that data structures no longer have conditionally defined fields, so they pay the cost of all fields regardless of whether they are used. In practice, this is only a minor concern; config_stats will go away in an upcoming change, and config_prof is the only other major feature that depends on more than a few special-purpose fields.
Diffstat (limited to 'src/ckh.c')
-rw-r--r--src/ckh.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/ckh.c b/src/ckh.c
index 43fcc25..f7eaa78 100644
--- a/src/ckh.c
+++ b/src/ckh.c
@@ -73,7 +73,7 @@ ckh_isearch(ckh_t *ckh, const void *key)
size_t hash1, hash2, bucket, cell;
assert(ckh != NULL);
- dassert(ckh->magic == CKH_MAGIC);
+ assert(ckh->magic == CKH_MAGIC);
ckh->hash(key, ckh->lg_curbuckets, &hash1, &hash2);
@@ -394,9 +394,8 @@ ckh_new(ckh_t *ckh, size_t minitems, ckh_hash_t *hash, ckh_keycomp_t *keycomp)
goto RETURN;
}
-#ifdef JEMALLOC_DEBUG
- ckh->magic = CKH_MAGIC;
-#endif
+ if (config_debug)
+ ckh->magic = CKH_MAGIC;
ret = false;
RETURN:
@@ -408,7 +407,7 @@ ckh_delete(ckh_t *ckh)
{
assert(ckh != NULL);
- dassert(ckh->magic == CKH_MAGIC);
+ assert(ckh->magic == CKH_MAGIC);
#ifdef CKH_VERBOSE
malloc_printf(
@@ -433,7 +432,7 @@ ckh_count(ckh_t *ckh)
{
assert(ckh != NULL);
- dassert(ckh->magic == CKH_MAGIC);
+ assert(ckh->magic == CKH_MAGIC);
return (ckh->count);
}
@@ -464,7 +463,7 @@ ckh_insert(ckh_t *ckh, const void *key, const void *data)
bool ret;
assert(ckh != NULL);
- dassert(ckh->magic == CKH_MAGIC);
+ assert(ckh->magic == CKH_MAGIC);
assert(ckh_search(ckh, key, NULL, NULL));
#ifdef CKH_COUNT
@@ -489,7 +488,7 @@ ckh_remove(ckh_t *ckh, const void *searchkey, void **key, void **data)
size_t cell;
assert(ckh != NULL);
- dassert(ckh->magic == CKH_MAGIC);
+ assert(ckh->magic == CKH_MAGIC);
cell = ckh_isearch(ckh, searchkey);
if (cell != SIZE_T_MAX) {
@@ -521,7 +520,7 @@ ckh_search(ckh_t *ckh, const void *searchkey, void **key, void **data)
size_t cell;
assert(ckh != NULL);
- dassert(ckh->magic == CKH_MAGIC);
+ assert(ckh->magic == CKH_MAGIC);
cell = ckh_isearch(ckh, searchkey);
if (cell != SIZE_T_MAX) {