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; + } } }