]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/cmdparse: pass cmdmap by const reference
authorKefu Chai <kchai@redhat.com>
Tue, 4 Feb 2020 08:56:31 +0000 (16:56 +0800)
committerRonen Friedman <rfriedma@redhat.com>
Thu, 13 Feb 2020 15:53:32 +0000 (17:53 +0200)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/cmdparse.cc
src/common/cmdparse.h

index 1827a13879895478c46182df39e88a5d7b425450..d09acd68f0edd7261d739a5957fd2bf3df607312 100644 (file)
@@ -281,15 +281,14 @@ void cmdmap_dump(const cmdmap_t &cmdmap, Formatter *f)
  * false, ss is valid */
 
 bool
-cmdmap_from_json(vector<string> cmd, cmdmap_t *mapp, stringstream &ss)
+cmdmap_from_json(const vector<string>& cmd, cmdmap_t *mapp, stringstream &ss)
 {
   json_spirit::mValue v;
 
   string fullcmd;
   // First, join all cmd strings
-  for (vector<string>::iterator it = cmd.begin();
-       it != cmd.end(); ++it)
-    fullcmd += *it;
+  for (auto& c : cmd)
+    fullcmd += c;
 
   try {
     if (!json_spirit::read(fullcmd, v))
index d552556e410116b4256e93b76d8cd445e1bea1a8..424ac812d7dc5cb64407965ff6f70e55f7bf02b3 100644 (file)
@@ -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<std::string> cmd, cmdmap_t *mapp,
+bool cmdmap_from_json(const std::vector<std::string>& 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);