From: Kefu Chai Date: Wed, 10 May 2017 03:15:32 +0000 (+0800) Subject: cmdparse: more constness X-Git-Tag: v12.1.0~10^2~113^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F15023%2Fhead;p=ceph.git cmdparse: more constness Signed-off-by: Kefu Chai --- diff --git a/src/common/cmdparse.cc b/src/common/cmdparse.cc index 3fdf94c73676..bf1a327b031b 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 104848dc2634..788b7097d462 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 16e455295252..92a3215e6cb7 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); }