]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/rgw: cls_rgw_obj_chain uses vector instead of list
authorCasey Bodley <cbodley@redhat.com>
Wed, 18 Sep 2024 16:31:09 +0000 (12:31 -0400)
committerCasey Bodley <cbodley@redhat.com>
Wed, 25 Sep 2024 12:31:52 +0000 (08:31 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/cls/rgw/cls_rgw_types.h
src/rgw/driver/rados/rgw_gc.cc
src/rgw/rgw_admin.cc
src/test/cls_rgw/test_cls_rgw.cc

index e6afe47ffc7d1c5d8d51f4055a365244baf3245a..1bfcbcc97b89eaf3657dfe0c0cc2cd3dfb06dca9 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <string>
 #include <list>
+#include <vector>
 #include <boost/container/flat_map.hpp>
 #include "common/ceph_time.h"
 #include "common/Formatter.h"
@@ -1197,16 +1198,14 @@ struct cls_rgw_obj {
 WRITE_CLASS_ENCODER(cls_rgw_obj)
 
 struct cls_rgw_obj_chain {
-  std::list<cls_rgw_obj> objs;
-
-  cls_rgw_obj_chain() {}
+  std::vector<cls_rgw_obj> objs;
 
   void push_obj(const std::string& pool, const cls_rgw_obj_key& key, const std::string& loc) {
     cls_rgw_obj obj;
     obj.pool = pool;
     obj.key = key;
     obj.loc = loc;
-    objs.push_back(obj);
+    objs.push_back(std::move(obj));
   }
 
   void encode(ceph::buffer::list& bl) const {
@@ -1223,9 +1222,9 @@ struct cls_rgw_obj_chain {
 
   void dump(ceph::Formatter *f) const {
     f->open_array_section("objs");
-    for (std::list<cls_rgw_obj>::const_iterator p = objs.begin(); p != objs.end(); ++p) {
+    for (const auto& o : objs) {
       f->open_object_section("obj");
-      p->dump(f);
+      o.dump(f);
       f->close_section();
     }
     f->close_section();
index 7a4e22608bdd7457e7ce19664952b9426e046d01..18c8b75ca4d83103ca9c13a580e9d7523e347f9e 100644 (file)
@@ -653,7 +653,6 @@ int RGWGC::process(int index, int max_secs, bool expired_only,
        info.tag << "', time=" << info.time << ", chain.objs.size()=" <<
        info.chain.objs.size() << dendl;
 
-      std::list<cls_rgw_obj>::iterator liter;
       cls_rgw_obj_chain& chain = info.chain;
 
       utime_t now = ceph_clock_now();
@@ -668,9 +667,7 @@ int RGWGC::process(int index, int max_secs, bool expired_only,
         }
       }
       if (! chain.objs.empty()) {
-       for (liter = chain.objs.begin(); liter != chain.objs.end(); ++liter) {
-         cls_rgw_obj& obj = *liter;
-
+       for (const auto& obj : chain.objs) {
          if (obj.pool != last_pool) {
            delete ctx;
            ctx = new IoCtx;
index d1b041f2423febad8a3203016b25d8a58b8ef5b7..a8874195217a2e92d6f903aafcaeea6efe001c28 100644 (file)
@@ -8806,10 +8806,7 @@ next:
        formatter->dump_string("tag", info.tag);
        formatter->dump_stream("time") << info.time;
        formatter->open_array_section("objs");
-        list<cls_rgw_obj>::iterator liter;
-       cls_rgw_obj_chain& chain = info.chain;
-       for (liter = chain.objs.begin(); liter != chain.objs.end(); ++liter) {
-         cls_rgw_obj& obj = *liter;
+       for (const auto& obj : info.chain.objs) {
           encode_json("obj", obj, formatter.get());
        }
        formatter->close_section(); // objs
index 23c3576429a694ce1bd661a8ac8595e4255e5c35..630f6b8ecd6c8c81bed08b91925d30667f68c0db 100644 (file)
@@ -854,7 +854,7 @@ TEST_F(cls_rgw, gc_set)
     /* verify expected num of objects in chain */
     ASSERT_EQ(2, (int)entry.chain.objs.size());
 
-    list<cls_rgw_obj>::iterator oiter = entry.chain.objs.begin();
+    auto oiter = entry.chain.objs.begin();
     cls_rgw_obj obj1, obj2;
 
     /* create expected objects */
@@ -932,7 +932,7 @@ TEST_F(cls_rgw, gc_list)
     /* verify expected num of objects in chain */
     ASSERT_EQ(2, (int)entry.chain.objs.size());
 
-    list<cls_rgw_obj>::iterator oiter = entry.chain.objs.begin();
+    auto oiter = entry.chain.objs.begin();
     cls_rgw_obj obj1, obj2;
 
     /* create expected objects */