From d39828c0a6ef882565d08ad399f6e2345ab5737e Mon Sep 17 00:00:00 2001 From: JiaShuo Date: Mon, 9 Mar 2020 18:13:46 +0800 Subject: [PATCH] update --- src/dist/replication/lib/replica_stub.cpp | 26 +++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/dist/replication/lib/replica_stub.cpp b/src/dist/replication/lib/replica_stub.cpp index 0cfba8a4f0..9652594a13 100644 --- a/src/dist/replication/lib/replica_stub.cpp +++ b/src/dist/replication/lib/replica_stub.cpp @@ -910,25 +910,29 @@ void replica_stub::on_query_disk_info(const query_disk_info_request &req, { zauto_read_lock l(_replicas_lock); bool app_existed = false; - for (auto replica : _replicas) { + for (const auto &replica : _replicas) { const app_info &info = *(replica.second)->get_app_info(); if (info.app_id == req.app_id) { app_existed = true; break; } } - for (auto closing_replica : _closing_replicas) { - const app_info &info = std::get<2>(closing_replica.second); - if (info.app_id == req.app_id && !app_existed) { - app_existed = true; - break; + if (!app_existed) { + for (const auto &closing_replica : _closing_replicas) { + const app_info &info = std::get<2>(closing_replica.second); + if (info.app_id == req.app_id) { + app_existed = true; + break; + } } } - for (auto closed_replica : _closed_replicas) { - const app_info &info = closed_replica.second.first; - if (info.app_id == req.app_id && !app_existed) { - app_existed = true; - break; + if (!app_existed) { + for (const auto &closed_replica : _closed_replicas) { + const app_info &info = closed_replica.second.first; + if (info.app_id == req.app_id) { + app_existed = true; + break; + } } }