Remove expensive asserts from NDEBUG builds

pull/1312/head
Craig Tiller 10 years ago
parent 62bc1846b7
commit b116c4f79d
  1. 6
      src/core/transport/stream_op.c
  2. 4
      src/core/transport/stream_op.h

@ -92,12 +92,14 @@ void grpc_stream_ops_unref_owned_objects(grpc_stream_op *ops, size_t nops) {
}
static void assert_contained_metadata_ok(grpc_stream_op *ops, size_t nops) {
#ifndef NDEBUG
size_t i;
for (i = 0; i < nops; i++) {
if (ops[i].type == GRPC_OP_METADATA) {
grpc_metadata_batch_assert_ok(&ops[i].data.metadata);
}
}
#endif
}
static void expandto(grpc_stream_op_buffer *sopb, size_t new_capacity) {
@ -183,6 +185,7 @@ void grpc_sopb_append(grpc_stream_op_buffer *sopb, grpc_stream_op *ops,
}
static void assert_valid_list(grpc_mdelem_list *list) {
#ifndef NDEBUG
grpc_linked_mdelem *l;
GPR_ASSERT((list->head == NULL) == (list->tail == NULL));
@ -198,12 +201,15 @@ static void assert_valid_list(grpc_mdelem_list *list) {
if (l->next) GPR_ASSERT(l->next->prev == l);
if (l->prev) GPR_ASSERT(l->prev->next == l);
}
#endif
}
#ifndef NDEBUG
void grpc_metadata_batch_assert_ok(grpc_metadata_batch *comd) {
assert_valid_list(&comd->list);
assert_valid_list(&comd->garbage);
}
#endif
void grpc_metadata_batch_init(grpc_metadata_batch *comd) {
comd->list.head = comd->list.tail = comd->garbage.head = comd->garbage.tail =

@ -113,7 +113,11 @@ void grpc_metadata_batch_filter(grpc_metadata_batch *comd,
grpc_mdelem *elem),
void *user_data);
#ifndef NDEBUG
void grpc_metadata_batch_assert_ok(grpc_metadata_batch *comd);
#else
#define grpc_metadata_batch_assert_ok(comd) do {} while (0)
#endif
/* Represents a single operation performed on a stream/transport */
typedef struct grpc_stream_op {

Loading…
Cancel
Save