From: Kefu Chai Date: Tue, 4 Feb 2020 08:56:31 +0000 (+0800) Subject: common/cmdparse: pass cmdmap by const reference X-Git-Tag: v15.1.1~419^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6df121443f66214877e36909ececb37c238dbc44;p=ceph.git common/cmdparse: pass cmdmap by const reference Signed-off-by: Kefu Chai --- diff --git a/src/common/cmdparse.cc b/src/common/cmdparse.cc index 1827a1387989..d09acd68f0ed 100644 --- a/src/common/cmdparse.cc +++ b/src/common/cmdparse.cc @@ -281,15 +281,14 @@ void cmdmap_dump(const cmdmap_t &cmdmap, Formatter *f) * false, ss is valid */ bool -cmdmap_from_json(vector cmd, cmdmap_t *mapp, stringstream &ss) +cmdmap_from_json(const vector& cmd, cmdmap_t *mapp, stringstream &ss) { json_spirit::mValue v; string fullcmd; // First, join all cmd strings - for (vector::iterator it = cmd.begin(); - it != cmd.end(); ++it) - fullcmd += *it; + for (auto& c : cmd) + fullcmd += c; try { if (!json_spirit::read(fullcmd, v)) diff --git a/src/common/cmdparse.h b/src/common/cmdparse.h index d552556e4101..424ac812d7dc 100644 --- a/src/common/cmdparse.h +++ b/src/common/cmdparse.h @@ -39,7 +39,7 @@ void dump_cmddesc_to_json(ceph::Formatter *jf, const std::string& module, const std::string& perm, uint64_t flags); -bool cmdmap_from_json(std::vector cmd, cmdmap_t *mapp, +bool cmdmap_from_json(const 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, const std::string& k, const char *name);