From 2fc8d873b95baffc72d93ea0fd639d7c31721b92 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 10 May 2017 11:15:32 +0800 Subject: [PATCH] cmdparse: more constness Signed-off-by: Kefu Chai --- src/common/cmdparse.cc | 2 +- src/common/cmdparse.h | 8 ++++---- src/mon/MDSMonitor.cc | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/common/cmdparse.cc b/src/common/cmdparse.cc index 3fdf94c736766..bf1a327b031b5 100644 --- a/src/common/cmdparse.cc +++ b/src/common/cmdparse.cc @@ -319,7 +319,7 @@ cmd_vartype_stringify(const cmd_vartype &v) void -handle_bad_get(CephContext *cct, string k, const char *tname) +handle_bad_get(CephContext *cct, const string& k, const char *tname) { ostringstream errstr; int status; diff --git a/src/common/cmdparse.h b/src/common/cmdparse.h index 104848dc26348..788b7097d4620 100644 --- a/src/common/cmdparse.h +++ b/src/common/cmdparse.h @@ -42,13 +42,13 @@ void dump_cmddesc_to_json(ceph::Formatter *jf, bool cmdmap_from_json(std::vector cmd, cmdmap_t *mapp, std::stringstream &ss); void cmdmap_dump(const cmdmap_t &cmdmap, ceph::Formatter *f); -void handle_bad_get(CephContext *cct, std::string k, const char *name); +void handle_bad_get(CephContext *cct, const std::string& k, const char *name); std::string cmd_vartype_stringify(const cmd_vartype& v); template bool -cmd_getval(CephContext *cct, const cmdmap_t& cmdmap, std::string k, T& val) +cmd_getval(CephContext *cct, const cmdmap_t& cmdmap, const std::string& k, T& val) { if (cmdmap.count(k)) { try { @@ -65,7 +65,7 @@ cmd_getval(CephContext *cct, const cmdmap_t& cmdmap, std::string k, T& val) template void -cmd_getval(CephContext *cct, cmdmap_t& cmdmap, std::string k, T& val, T defval) +cmd_getval(CephContext *cct, const cmdmap_t& cmdmap, const std::string& k, T& val, const T& defval) { if (!cmd_getval(cct, cmdmap, k, val)) val = defval; @@ -73,7 +73,7 @@ cmd_getval(CephContext *cct, cmdmap_t& cmdmap, std::string k, T& val, T defval) template void -cmd_putval(CephContext *cct, cmdmap_t& cmdmap, std::string k, T val) +cmd_putval(CephContext *cct, cmdmap_t& cmdmap, const std::string& k, const T& val) { cmdmap[k] = val; } diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 16e4552952525..92a3215e6cb75 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -53,19 +53,19 @@ static ostream& _prefix(std::ostream *_dout, Monitor *mon, FSMap const& fsmap) { * out strongly-typedef'd types */ template<> bool cmd_getval(CephContext *cct, const cmdmap_t& cmdmap, - std::string k, mds_gid_t &val) + const std::string& k, mds_gid_t &val) { return cmd_getval(cct, cmdmap, k, (int64_t&)val); } template<> bool cmd_getval(CephContext *cct, const cmdmap_t& cmdmap, - std::string k, mds_rank_t &val) + const std::string& k, mds_rank_t &val) { return cmd_getval(cct, cmdmap, k, (int64_t&)val); } template<> bool cmd_getval(CephContext *cct, const cmdmap_t& cmdmap, - std::string k, MDSMap::DaemonState &val) + const std::string& k, MDSMap::DaemonState &val) { return cmd_getval(cct, cmdmap, k, (int64_t&)val); } -- 2.39.5