aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-04-20 10:07:36 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-04-20 10:07:36 -0700
commitb116c4f79d601e22b8634ad0f6052e4f3bf07d97 (patch)
tree127e5783bdb660817445bc04a8203ceeb28007c5
parent62bc1846b7a2d83cbdd9e31ac3921f76df570098 (diff)
Remove expensive asserts from NDEBUG builds
-rw-r--r--src/core/transport/stream_op.c6
-rw-r--r--src/core/transport/stream_op.h4
2 files changed, 10 insertions, 0 deletions
diff --git a/src/core/transport/stream_op.c b/src/core/transport/stream_op.c
index f3e634d853..ed31ec59a1 100644
--- a/src/core/transport/stream_op.c
+++ b/src/core/transport/stream_op.c
@@ -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 =
diff --git a/src/core/transport/stream_op.h b/src/core/transport/stream_op.h
index f6ce140bd8..20146b9af2 100644
--- a/src/core/transport/stream_op.h
+++ b/src/core/transport/stream_op.h
@@ -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 {