]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: avoid str copy in parse 25640/head
authorJos Collin <jcollin@redhat.com>
Thu, 20 Dec 2018 15:20:33 +0000 (20:50 +0530)
committerJos Collin <jcollin@redhat.com>
Sat, 29 Dec 2018 14:33:39 +0000 (20:03 +0530)
Avoids the input string copy.
It doesn't make any difference when the input string is copied.

Signed-off-by: Jos Collin <jcollin@redhat.com>
src/mon/MonCap.cc

index c1d7c7123003b2ceacd74e0df0fb69443b582ee5..29d81d44ac67539772a167687719a1c6dc98863c 100644 (file)
@@ -601,14 +601,11 @@ struct MonCapParser : qi::grammar<Iterator, MonCap()>
 
 bool MonCap::parse(const string& str, ostream *err)
 {
-  string s = str;
-  string::iterator iter = s.begin();
-  string::iterator end = s.end();
-
-  MonCapParser<string::iterator> g;
-  bool r = qi::parse(iter, end, g, *this);
-  //MonCapGrant foo;
-  //bool r = qi::phrase_parse(iter, end, g, ascii::space, foo);
+  auto iter = str.begin();
+  auto end = str.end();
+
+  MonCapParser<string::const_iterator> exp;
+  bool r = qi::parse(iter, end, exp, *this);
   if (r && iter == end) {
     text = str;
     for (auto& g : grants) {