From: Kefu Chai Date: Sun, 1 Oct 2017 06:40:55 +0000 (+0800) Subject: osd,mon: switch from vectors_equal() to operator==() X-Git-Tag: v13.0.1~652^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d221aba2d757c0449a83f0e8b9bf6648c78c15cf;p=ceph.git osd,mon: switch from vectors_equal() to operator==() 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 --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 877281570abf..e2b459a28af0 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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; } diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index c9db12c0f030..d040f390e6bf 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -1527,7 +1527,7 @@ void OSDMap::clean_temps(CephContext *cct, vector 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 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); diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index 0fbbaf236b1b..062f024e3d81 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -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 -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