From c42d844d27bc76c817c53802b3e1cf09a2360d04 Mon Sep 17 00:00:00 2001 From: yang-g Date: Wed, 15 Feb 2017 00:05:00 -0800 Subject: Let ServerContext own the initial_metadata array for sync calls --- src/cpp/server/server_context.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/cpp/server/server_context.cc') diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc index 6edbc90927..05c05c8695 100644 --- a/src/cpp/server/server_context.cc +++ b/src/cpp/server/server_context.cc @@ -33,7 +33,9 @@ #include +#include #include +#include #include #include @@ -133,8 +135,7 @@ ServerContext::ServerContext() sent_initial_metadata_(false), compression_level_set_(false) {} -ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata* metadata, - size_t metadata_count) +ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata_array* arr) : completion_op_(nullptr), has_notify_when_done_tag_(false), async_notify_when_done_tag_(nullptr), @@ -143,12 +144,8 @@ ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata* metadata, cq_(nullptr), sent_initial_metadata_(false), compression_level_set_(false) { - for (size_t i = 0; i < metadata_count; i++) { - client_metadata_.map()->insert( - std::pair( - StringRefFromSlice(&metadata[i].key), - StringRefFromSlice(&metadata[i].value))); - } + std::swap(*client_metadata_.arr(), *arr); + client_metadata_.FillMap(); } ServerContext::~ServerContext() { -- cgit v1.2.3