]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
messages/MOSDPGInfo: add a ctor for moving pg_list
authorKefu Chai <kchai@redhat.com>
Mon, 25 Feb 2019 16:29:08 +0000 (00:29 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 16 Mar 2019 06:22:59 +0000 (14:22 +0800)
* use delegating constructor for less repeating
* add a constructor for movable pg_list parameter: less memcpy().

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/messages/MOSDPGInfo.h

index 461a0fa65e72d73520a6d65ec1b84ede7bb19fbe..f7ba4aedf9fccc56b25e4c0d1312ba67613d6ac1 100644 (file)
@@ -29,17 +29,22 @@ private:
   epoch_t epoch = 0;
 
 public:
-  vector<pair<pg_notify_t,PastIntervals> > pg_list;
+  using pg_list_t = std::vector<std::pair<pg_notify_t,PastIntervals>>;
+  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: