]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: use str_join instead of std::copy
authorSage Weil <sage@inktank.com>
Thu, 15 Aug 2013 21:37:07 +0000 (14:37 -0700)
committerSage Weil <sage@inktank.com>
Thu, 15 Aug 2013 21:38:16 +0000 (14:38 -0700)
The std::copy method leaves a trailing separator.

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
(cherry picked from commit 35565ee64e41d7fddc7849c6006692c78227132c)

src/mon/LogMonitor.cc
src/mon/Monitor.cc

index cab49060082032787725cb0572aa3a400e5d7953..29e23ebdf3f7c8cb05702ac938ceb6e5162f002d 100644 (file)
@@ -29,6 +29,7 @@
 #include "common/errno.h"
 #include "common/config.h"
 #include "include/assert.h"
+#include "include/str_list.h"
 
 #define dout_subsys ceph_subsys_mon
 #undef dout_prefix
@@ -372,15 +373,12 @@ bool LogMonitor::prepare_command(MMonCommand *m)
   if (prefix == "log") {
     vector<string> logtext;
     cmd_getval(g_ceph_context, cmdmap, "logtext", logtext);
-    ostringstream ds;
-    std::copy(logtext.begin(), logtext.end(),
-             ostream_iterator<string>(ds, " "));
     LogEntry le;
     le.who = m->get_orig_source_inst();
     le.stamp = m->get_recv_stamp();
     le.seq = 0;
     le.type = CLOG_INFO;
-    le.msg = ds.str();
+    le.msg = str_join(logtext, " ");
     pending_summary.add(le);
     pending_log.insert(pair<utime_t,LogEntry>(le.stamp, le));
     wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, string(), get_last_committed()));
index a9d3e48a3bea87a4509facaac3abc3243fad8090..601cdbab47b06f9c4c1162ee88834187afae3476 100644 (file)
@@ -2067,11 +2067,8 @@ void Monitor::handle_command(MMonCommand *m)
     cmd_getval(g_ceph_context, cmdmap, "injected_args", injected_args);
     if (!injected_args.empty()) {
       dout(0) << "parsing injected options '" << injected_args << "'" << dendl;
-      ostringstream argss;
-      std::copy(injected_args.begin(), injected_args.end(),
-               ostream_iterator<string>(argss, " "));
       ostringstream oss;
-      r = g_conf->injectargs(argss.str().c_str(), &oss);
+      r = g_conf->injectargs(str_join(injected_args, " "), &oss);
       ss << "injectargs:"  << oss.str();
       rs = ss.str();
       goto out;
@@ -2154,10 +2151,7 @@ void Monitor::handle_command(MMonCommand *m)
 
     vector<string> tagsvec;
     cmd_getval(g_ceph_context, cmdmap, "tags", tagsvec);
-    stringstream tags;
-    std::copy(tagsvec.begin(), tagsvec.end(),
-             ostream_iterator<string>(tags, " "));
-    string tagstr = tags.str();
+    string tagstr = str_join(tagsvec, " ");
     if (!tagstr.empty())
       tagstr = tagstr.substr(0, tagstr.find_last_of(' '));
     f->dump_string("tag", tagstr);