From: Kefu Chai Date: Mon, 25 Feb 2019 16:29:08 +0000 (+0800) Subject: messages/MOSDPGInfo: add a ctor for moving pg_list X-Git-Tag: v15.0.0~189^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ca7e68951dd007fb84a693d8e30bf2c1a4246b00;p=ceph.git messages/MOSDPGInfo: add a ctor for moving pg_list * use delegating constructor for less repeating * add a constructor for movable pg_list parameter: less memcpy(). Signed-off-by: Kefu Chai --- diff --git a/src/messages/MOSDPGInfo.h b/src/messages/MOSDPGInfo.h index 461a0fa65e72..f7ba4aedf9fc 100644 --- a/src/messages/MOSDPGInfo.h +++ b/src/messages/MOSDPGInfo.h @@ -29,17 +29,22 @@ private: epoch_t epoch = 0; public: - vector > pg_list; + using pg_list_t = std::vector>; + pg_list_t pg_list; epoch_t get_epoch() const { return epoch; } MOSDPGInfo() - : MessageInstance(MSG_OSD_PG_INFO, HEAD_VERSION, COMPAT_VERSION) { - set_priority(CEPH_MSG_PRIO_HIGH); - } - MOSDPGInfo(version_t mv) + : MOSDPGInfo{0, {}} + {} + MOSDPGInfo(epoch_t mv) + : MOSDPGInfo(mv, {}) + {} + MOSDPGInfo(epoch_t mv, pg_list_t&& l) : MessageInstance(MSG_OSD_PG_INFO, HEAD_VERSION, COMPAT_VERSION), - epoch(mv) { + epoch{mv}, + pg_list{std::move(l)} + { set_priority(CEPH_MSG_PRIO_HIGH); } private: