From: Kefu Chai Date: Mon, 24 Aug 2020 09:11:40 +0000 (+0800) Subject: test/osd: use stack for ObjectDesc::iterator::stack X-Git-Tag: v17.0.0~1311^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=7f32c707407efb500e9683c3bbe6ca5b9e1be66a;p=ceph.git test/osd: use stack for ObjectDesc::iterator::stack better readability this way Signed-off-by: Kefu Chai --- diff --git a/src/test/osd/Object.cc b/src/test/osd/Object.cc index 12f946f5650b2..9d914abd7944d 100644 --- a/src/test/osd/Object.cc +++ b/src/test/osd/Object.cc @@ -82,28 +82,23 @@ void VarLenGenerator::get_ranges_map( } void ObjectDesc::iterator::adjust_stack() { - while (!stack.empty() && pos >= stack.front().second.next) { - ceph_assert(pos == stack.front().second.next); - size = stack.front().second.size; - current = stack.front().first; - stack.pop_front(); + while (!stack.empty() && pos >= stack.top().second.next) { + ceph_assert(pos == stack.top().second.next); + size = stack.top().second.size; + current = stack.top().first; + stack.pop(); } if (stack.empty()) { cur_valid_till = std::numeric_limits::max(); } else { - cur_valid_till = stack.front().second.next; + cur_valid_till = stack.top().second.next; } while (current != layers.end() && !current->covers(pos)) { uint64_t next = current->next(pos); if (next < cur_valid_till) { - stack.push_front( - make_pair( - current, - StackState{next, size} - ) - ); + stack.emplace(current, StackState{next, size}); cur_valid_till = next; } diff --git a/src/test/osd/Object.h b/src/test/osd/Object.h index 9de1e83af0d1c..a78a598236d02 100644 --- a/src/test/osd/Object.h +++ b/src/test/osd/Object.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #ifndef OBJECT_H @@ -369,14 +370,16 @@ public: std::numeric_limits::max(); } }; - std::list layers; + // from latest to earliest + using layers_t = std::vector; + layers_t layers; struct StackState { const uint64_t next; const uint64_t size; }; - std::list::iterator, StackState> > stack; - std::list::iterator current; + std::stack > stack; + layers_t::iterator current; explicit iterator(ObjectDesc &obj) : pos(0),