Remove another range-based for

Do not make explicit comparisons against nullptr; only use
implicit typecast to bool
pull/6863/head
Vijay Pai 9 years ago
parent ce350a5925
commit b645a2d3ce
  1. 6
      src/cpp/server/server.cc
  2. 7
      src/cpp/server/server_builder.cc

@ -67,7 +67,7 @@ static std::shared_ptr<Server::GlobalCallbacks> g_callbacks = nullptr;
static gpr_once g_once_init_callbacks = GPR_ONCE_INIT;
static void InitGlobalCallbacks() {
if (g_callbacks == nullptr) {
if (!g_callbacks) {
g_callbacks.reset(new DefaultGlobalCallbacks());
}
}
@ -324,8 +324,8 @@ Server::~Server() {
}
void Server::SetGlobalCallbacks(GlobalCallbacks* callbacks) {
GPR_ASSERT(g_callbacks == nullptr);
GPR_ASSERT(callbacks != nullptr);
GPR_ASSERT(!g_callbacks);
GPR_ASSERT(callbacks);
g_callbacks.reset(callbacks);
}

@ -54,7 +54,8 @@ ServerBuilder::ServerBuilder()
: max_message_size_(-1), generic_service_(nullptr) {
grpc_compression_options_init(&compression_options_);
gpr_once_init(&once_init_plugin_list, do_plugin_list_init);
for (auto factory : (*g_plugin_factory_list)) {
for (auto it = g_plugin_factory_list->begin(); it != g_plugin_factory_list->end(); it++) {
auto& factory = *it;
std::unique_ptr<ServerBuilderPlugin> plugin = factory();
plugins_[plugin->name()] = std::move(plugin);
}
@ -103,7 +104,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;
@ -115,7 +116,7 @@ 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()) {
thread_pool.reset(CreateDefaultThreadPool());

Loading…
Cancel
Save