diff options
Diffstat (limited to 'src/cpp/server/server_builder.cc')
-rw-r--r-- | src/cpp/server/server_builder.cc | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index 279981744a..45bb858e2e 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -55,9 +55,10 @@ static void do_plugin_list_init(void) { ServerBuilder::ServerBuilder() : max_message_size_(-1), generic_service_(nullptr) { gpr_once_init(&once_init_plugin_list, do_plugin_list_init); - for (auto factory : (*g_plugin_factory_list)) { - std::unique_ptr<ServerBuilderPlugin> plugin = factory(); - plugins_[plugin->name()] = std::move(plugin); + for (auto it = g_plugin_factory_list->begin(); + it != g_plugin_factory_list->end(); it++) { + auto& factory = *it; + plugins_.emplace_back(factory()); } // all compression algorithms enabled by default. enabled_compression_algorithms_bitset_ = @@ -141,7 +142,7 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() { bool has_sync_methods = false; for (auto it = services_.begin(); it != services_.end(); ++it) { if ((*it)->service->has_synchronous_methods()) { - if (thread_pool == nullptr) { + if (!thread_pool) { thread_pool.reset(CreateDefaultThreadPool()); has_sync_methods = true; break; @@ -153,9 +154,9 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() { (*option)->UpdateArguments(&args); (*option)->UpdatePlugins(&plugins_); } - if (thread_pool == nullptr) { + if (!thread_pool) { for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) { - if ((*plugin).second->has_sync_methods()) { + if ((*plugin)->has_sync_methods()) { thread_pool.reset(CreateDefaultThreadPool()); has_sync_methods = true; break; @@ -212,7 +213,7 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() { } } for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) { - (*plugin).second->InitServer(initializer); + (*plugin)->InitServer(initializer); } if (generic_service_) { server->RegisterAsyncGenericService(generic_service_); @@ -238,7 +239,7 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() { return nullptr; } for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) { - (*plugin).second->Finish(initializer); + (*plugin)->Finish(initializer); } return server; } |