Skip to content

Some validations are always disabled #26

@TIGirardi

Description

@TIGirardi

These should probably be #ifndef. In particular, the first would catch #24

#ifdef NDEBUG
static void
_map_node_array_validate(void *o)
{
assert(IS_ARRAY_NODE(o));
MapNode_Array *node = (MapNode_Array*)(o);
Py_ssize_t i = 0, count = 0;
for (; i < HAMT_ARRAY_NODE_SIZE; i++) {
if (node->a_array[i] != NULL) {
count++;
}
}
assert(count == node->a_count);
}
#define VALIDATE_ARRAY_NODE(NODE) \
do { _map_node_array_validate(NODE); } while (0);
#else
#define VALIDATE_ARRAY_NODE(NODE)
#endif

immutables/immutables/_map.c

Lines 1112 to 1120 in 11863b2

#ifdef NDEBUG
/* Ensure that Collision.without implementation
converts to Bitmap nodes itself.
*/
if (IS_COLLISION_NODE(sub_node)) {
assert(map_node_collision_count(
(MapNode_Collision*)sub_node) > 1);
}
#endif

immutables/immutables/_map.c

Lines 2009 to 2018 in 11863b2

#ifdef NDEBUG
if (IS_COLLISION_NODE(node)) {
assert(
(map_node_collision_count(
(MapNode_Collision*)node)) > 1);
}
else if (IS_ARRAY_NODE(node)) {
assert(((MapNode_Array*)node)->a_count >= 16);
}
#endif

immutables/immutables/_map.c

Lines 2301 to 2304 in 11863b2

#ifdef NDEBUG
assert(iter->i_level >= 0);
iter->i_nodes[iter->i_level] = NULL;
#endif

immutables/immutables/_map.c

Lines 2338 to 2341 in 11863b2

#ifdef NDEBUG
assert(iter->i_level >= 0);
iter->i_nodes[iter->i_level] = NULL;
#endif

immutables/immutables/_map.c

Lines 2362 to 2365 in 11863b2

#ifdef NDEBUG
assert(iter->i_level >= 0);
iter->i_nodes[iter->i_level] = NULL;
#endif

immutables/immutables/_map.c

Lines 2384 to 2387 in 11863b2

#ifdef NDEBUG
assert(iter->i_level >= 0);
iter->i_nodes[iter->i_level] = NULL;
#endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions