From: Kefu Chai Date: Tue, 26 Feb 2019 08:42:19 +0000 (+0800) Subject: messages/MOSDPGQuery: add a ctor for moving pg_list X-Git-Tag: v15.0.0~189^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2f4689fa74d3cbb46763a2685d3c0907ef4827ab;p=ceph.git messages/MOSDPGQuery: add a ctor for moving pg_list * add a constructor for movable pg_list parameter: less memcpy(). Signed-off-by: Kefu Chai --- diff --git a/src/messages/MOSDPGQuery.h b/src/messages/MOSDPGQuery.h index d1d9ecd9156a..c9f3f8e4e704 100644 --- a/src/messages/MOSDPGQuery.h +++ b/src/messages/MOSDPGQuery.h @@ -34,19 +34,20 @@ private: public: version_t get_epoch() const { return epoch; } - map pg_list; + using pg_list_t = std::map; + pg_list_t pg_list; MOSDPGQuery() : MessageInstance(MSG_OSD_PG_QUERY, HEAD_VERSION, COMPAT_VERSION) { set_priority(CEPH_MSG_PRIO_HIGH); } - MOSDPGQuery(epoch_t e, map& ls) : + MOSDPGQuery(epoch_t e, pg_list_t&& ls) : MessageInstance(MSG_OSD_PG_QUERY, HEAD_VERSION, COMPAT_VERSION), - epoch(e) { - pg_list.swap(ls); + epoch(e), + pg_list(std::move(ls)) { set_priority(CEPH_MSG_PRIO_HIGH); } private: diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index e511fa4e79b8..a52625e24b09 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -9213,7 +9213,8 @@ void OSD::do_queries(map >& query_map, service.share_map_peer(who, con.get(), curmap); dout(7) << __func__ << " querying osd." << who << " on " << pit->second.size() << " PGs" << dendl; - MOSDPGQuery *m = new MOSDPGQuery(curmap->get_epoch(), pit->second); + MOSDPGQuery *m = new MOSDPGQuery(curmap->get_epoch(), + std::move(pit->second)); con->send_message(m); } }