]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: RGWObjManifest::obj_iterator: init member variables in-class
authorKefu Chai <kchai@redhat.com>
Sun, 25 Aug 2019 01:07:48 +0000 (09:07 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 27 Aug 2019 04:41:57 +0000 (12:41 +0800)
* remove the init() member function which is solely used by the
  constructors.
* use constructor delegation to minimize the repeating

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

index 3912b5048e55dbda932331a62a06d5b046e199cd..59abaf36abee6849a90c8284d1f5e77d06c07af9 100644 (file)
@@ -419,14 +419,14 @@ public:
   }
 
   class obj_iterator {
-    RGWObjManifest *manifest;
-    uint64_t part_ofs; /* where current part starts */
-    uint64_t stripe_ofs; /* where current stripe starts */
-    uint64_t ofs;       /* current position within the object */
-    uint64_t stripe_size;      /* current part size */
-
-    int cur_part_id;
-    int cur_stripe;
+    RGWObjManifest *manifest = nullptr;
+    uint64_t part_ofs = 0;   /* where current part starts */
+    uint64_t stripe_ofs = 0; /* where current stripe starts */
+    uint64_t ofs = 0;        /* current position within the object */
+    uint64_t stripe_size = 0;      /* current part size */
+
+    int cur_part_id = 0;
+    int cur_stripe = 0;
     string cur_override_prefix;
 
     rgw_obj_select location;
@@ -436,15 +436,6 @@ public:
 
     map<uint64_t, RGWObjManifestPart>::iterator explicit_iter;
 
-    void init() {
-      part_ofs = 0;
-      stripe_ofs = 0;
-      ofs = 0;
-      stripe_size = 0;
-      cur_part_id = 0;
-      cur_stripe = 0;
-    }
-
     void update_explicit_pos();
 
 
@@ -455,17 +446,11 @@ public:
     }
 
   public:
-    obj_iterator() : manifest(NULL) {
-      init();
-    }
-    explicit obj_iterator(RGWObjManifest *_m) : manifest(_m) {
-      init();
-      if (!manifest->empty()) {
-        seek(0);
-      }
-    }
+    obj_iterator() = default;
+    explicit obj_iterator(RGWObjManifest *_m)
+      : obj_iterator(_m, 0)
+    {}
     obj_iterator(RGWObjManifest *_m, uint64_t _ofs) : manifest(_m) {
-      init();
       if (!manifest->empty()) {
         seek(_ofs);
       }