Remove expensive asserts from NDEBUG builds
diff --git a/src/core/transport/stream_op.c b/src/core/transport/stream_op.c
index f3e634d..ed31ec5 100644
--- a/src/core/transport/stream_op.c
+++ b/src/core/transport/stream_op.c
@@ -92,12 +92,14 @@
}
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 @@
}
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 @@
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 =
diff --git a/src/core/transport/stream_op.h b/src/core/transport/stream_op.h
index f6ce140..20146b9 100644
--- a/src/core/transport/stream_op.h
+++ b/src/core/transport/stream_op.h
@@ -113,7 +113,11 @@
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 {