]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd,mon: switch from vectors_equal() to operator==() 18064/head
authorKefu Chai <kchai@redhat.com>
Sun, 1 Oct 2017 06:40:55 +0000 (14:40 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 1 Oct 2017 07:09:03 +0000 (15:09 +0800)
std::equal() in c++11 is able to compare elements of different container
types. but would be easier to read if we can just use the operator==().

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mon/OSDMonitor.cc
src/osd/OSDMap.cc
src/osd/OSDMap.h

index 877281570abf354e314c95d3a1ca4e7bf235f78e..e2b459a28af06b9032dee36249cea4602db21b95 100644 (file)
@@ -2690,7 +2690,7 @@ bool OSDMonitor::preprocess_pgtemp(MonOpRequestRef op)
     //        an existing pg_primary field to imply a change
     if (p->second.size() &&
        (osdmap.pg_temp->count(p->first) == 0 ||
-        !vectors_equal(osdmap.pg_temp->get(p->first), p->second) ||
+        osdmap.pg_temp->get(p->first) != p->second ||
         osdmap.primary_temp->count(p->first)))
       return false;
   }
index c9db12c0f03027c46ed29459008702f3e067f8ce..d040f390e6bfd5586ab1d30bf8c89e4e1cb1b2a4 100644 (file)
@@ -1527,7 +1527,7 @@ void OSDMap::clean_temps(CephContext *cct,
     vector<int> raw_up;
     int primary;
     tmpmap.pg_to_raw_up(pg.first, &raw_up, &primary);
-    if (vectors_equal(raw_up, pg.second)) {
+    if (raw_up == pg.second) {
       ldout(cct, 10) << __func__ << "  removing pg_temp " << pg.first << " "
                     << pg.second << " that matches raw_up mapping" << dendl;
       if (osdmap.pg_temp->count(pg.first))
@@ -3712,7 +3712,7 @@ int OSDMap::clean_pg_upmaps(
     vector<int> raw;
     int primary;
     pg_to_raw_osds(p.first, &raw, &primary);
-    if (vectors_equal(raw, p.second)) {
+    if (raw == p.second) {
       ldout(cct, 10) << " removing redundant pg_upmap " << p.first << " "
                     << p.second << dendl;
       pending_inc->old_pg_upmap.insert(p.first);
index 0fbbaf236b1b675d89cae365a4bbebd51030847d..062f024e3d811a39fa87ce1d79b0029a6405539a 100644 (file)
@@ -43,18 +43,6 @@ class CephContext;
 class CrushWrapper;
 class health_check_map_t;
 
-// FIXME C++11 does not have std::equal for two differently-typed containers.
-// use this until we move to c++14
-template<typename A, typename B>
-bool vectors_equal(A a, B b)
-{
-  return
-    a.size() == b.size() &&
-    (a.empty() ||
-     memcmp((char*)&a[0], (char*)&b[0], sizeof(a[0]) * a.size()) == 0);
-}
-
-
 /*
  * we track up to two intervals during which the osd was alive and
  * healthy.  the most recent is [up_from,up_thru), where up_thru is