]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MonMap: add more const'ness to its methods 23709/head
authorKefu Chai <kchai@redhat.com>
Thu, 23 Aug 2018 11:59:55 +0000 (19:59 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 23 Aug 2018 12:03:15 +0000 (20:03 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mon/MonMap.h

index d7e902fcd37e8712828f0eb04c5399e96e8ae113..5e91a7d860a39d603c6b19bc208db59ae9ed3e3e 100644 (file)
@@ -268,13 +268,15 @@ public:
       return p->second;
   }
 
-  int get_rank(const string& n) {
-    for (unsigned i = 0; i < ranks.size(); i++)
-      if (ranks[i] == n)
-       return i;
-    return -1;
+  int get_rank(const string& n) const {
+    if (auto found = std::find(ranks.begin(), ranks.end(), n);
+       found != ranks.end()) {
+      return std::distance(ranks.begin(), found);
+    } else {
+      return -1;
+    }
   }
-  int get_rank(const entity_addr_t& a) {
+  int get_rank(const entity_addr_t& a) const {
     string n = get_name(a);
     if (n.empty())
       return -1;