From 5c2b16e89001e460a8f7d99820a9e110c9810526 Mon Sep 17 00:00:00 2001 From: Dan Wang Date: Fri, 22 Nov 2024 17:33:10 +0800 Subject: [PATCH] fix suggestion --- src/meta/server_state.cpp | 5 +---- src/meta/server_state.h | 17 ++++------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/meta/server_state.cpp b/src/meta/server_state.cpp index b53132fbfd..6f2c2a6f8f 100644 --- a/src/meta/server_state.cpp +++ b/src/meta/server_state.cpp @@ -3033,10 +3033,7 @@ void server_state::set_app_envs(const app_env_rpc &env_rpc) } if (s == "dropping") { - const auto &iter = _exist_apps.find(app_name); - CHECK_TRUE(iter != _exist_apps.end()); - - iter->second->status = app_status::AS_DROPPING; + gutil::FindOrDie(_exist_apps, app_name)->status = app_status::AS_DROPPING; return; } }); diff --git a/src/meta/server_state.h b/src/meta/server_state.h index 6d03f9d7b3..5b6d2885af 100644 --- a/src/meta/server_state.h +++ b/src/meta/server_state.h @@ -42,6 +42,7 @@ #include "common/gpid.h" #include "common/manual_compact.h" #include "dsn.layer2_types.h" +#include "gutil/map_util.h" #include "meta/meta_rpc_types.h" #include "meta_data.h" #include "table_metrics.h" @@ -143,24 +144,14 @@ class server_state meta_view get_meta_view() { return {&_all_apps, &_nodes}; } - std::shared_ptr get_app(const std::string &name) const + std::shared_ptr get_app(const std::string &app_name) const { - const auto &iter = _exist_apps.find(name); - if (iter == _exist_apps.end()) { - return {}; - } - - return iter->second; + return gutil::FindWithDefault(_exist_apps, app_name); } std::shared_ptr get_app(int32_t app_id) const { - const auto &iter = _all_apps.find(app_id); - if (iter == _all_apps.end()) { - return {}; - } - - return iter->second; + return gutil::FindWithDefault(_all_apps, app_id); } void query_configuration_by_index(const query_cfg_request &request,