Skip to content

Commit e39f601

Browse files
committed
cls/rgw: cls_rgw_obj_chain uses vector instead of list
Signed-off-by: Casey Bodley <[email protected]>
1 parent cbbddfd commit e39f601

File tree

4 files changed

+9
-16
lines changed

4 files changed

+9
-16
lines changed

src/cls/rgw/cls_rgw_types.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <string>
77
#include <list>
8+
#include <vector>
89
#include <boost/container/flat_map.hpp>
910
#include "common/ceph_time.h"
1011
#include "common/Formatter.h"
@@ -1197,16 +1198,14 @@ struct cls_rgw_obj {
11971198
WRITE_CLASS_ENCODER(cls_rgw_obj)
11981199

11991200
struct cls_rgw_obj_chain {
1200-
std::list<cls_rgw_obj> objs;
1201-
1202-
cls_rgw_obj_chain() {}
1201+
std::vector<cls_rgw_obj> objs;
12031202

12041203
void push_obj(const std::string& pool, const cls_rgw_obj_key& key, const std::string& loc) {
12051204
cls_rgw_obj obj;
12061205
obj.pool = pool;
12071206
obj.key = key;
12081207
obj.loc = loc;
1209-
objs.push_back(obj);
1208+
objs.push_back(std::move(obj));
12101209
}
12111210

12121211
void encode(ceph::buffer::list& bl) const {
@@ -1223,9 +1222,9 @@ struct cls_rgw_obj_chain {
12231222

12241223
void dump(ceph::Formatter *f) const {
12251224
f->open_array_section("objs");
1226-
for (std::list<cls_rgw_obj>::const_iterator p = objs.begin(); p != objs.end(); ++p) {
1225+
for (const auto& o : objs) {
12271226
f->open_object_section("obj");
1228-
p->dump(f);
1227+
o.dump(f);
12291228
f->close_section();
12301229
}
12311230
f->close_section();

src/rgw/driver/rados/rgw_gc.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,6 @@ int RGWGC::process(int index, int max_secs, bool expired_only,
653653
info.tag << "', time=" << info.time << ", chain.objs.size()=" <<
654654
info.chain.objs.size() << dendl;
655655

656-
std::list<cls_rgw_obj>::iterator liter;
657656
cls_rgw_obj_chain& chain = info.chain;
658657

659658
utime_t now = ceph_clock_now();
@@ -668,9 +667,7 @@ int RGWGC::process(int index, int max_secs, bool expired_only,
668667
}
669668
}
670669
if (! chain.objs.empty()) {
671-
for (liter = chain.objs.begin(); liter != chain.objs.end(); ++liter) {
672-
cls_rgw_obj& obj = *liter;
673-
670+
for (const auto& obj : chain.objs) {
674671
if (obj.pool != last_pool) {
675672
delete ctx;
676673
ctx = new IoCtx;

src/rgw/rgw_admin.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8806,10 +8806,7 @@ int main(int argc, const char **argv)
88068806
formatter->dump_string("tag", info.tag);
88078807
formatter->dump_stream("time") << info.time;
88088808
formatter->open_array_section("objs");
8809-
list<cls_rgw_obj>::iterator liter;
8810-
cls_rgw_obj_chain& chain = info.chain;
8811-
for (liter = chain.objs.begin(); liter != chain.objs.end(); ++liter) {
8812-
cls_rgw_obj& obj = *liter;
8809+
for (const auto& obj : info.chain.objs) {
88138810
encode_json("obj", obj, formatter.get());
88148811
}
88158812
formatter->close_section(); // objs

src/test/cls_rgw/test_cls_rgw.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ TEST_F(cls_rgw, gc_set)
854854
/* verify expected num of objects in chain */
855855
ASSERT_EQ(2, (int)entry.chain.objs.size());
856856

857-
list<cls_rgw_obj>::iterator oiter = entry.chain.objs.begin();
857+
auto oiter = entry.chain.objs.begin();
858858
cls_rgw_obj obj1, obj2;
859859

860860
/* create expected objects */
@@ -932,7 +932,7 @@ TEST_F(cls_rgw, gc_list)
932932
/* verify expected num of objects in chain */
933933
ASSERT_EQ(2, (int)entry.chain.objs.size());
934934

935-
list<cls_rgw_obj>::iterator oiter = entry.chain.objs.begin();
935+
auto oiter = entry.chain.objs.begin();
936936
cls_rgw_obj obj1, obj2;
937937

938938
/* create expected objects */

0 commit comments

Comments
 (0)