mirror of
https://github.com/ceph/ceph
synced 2025-01-03 09:32:43 +00:00
test/osd: use stack for ObjectDesc::iterator::stack
better readability this way Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
parent
ca00bb7927
commit
7f32c70740
@ -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<uint64_t>::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;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <stack>
|
||||
#include <random>
|
||||
|
||||
#ifndef OBJECT_H
|
||||
@ -369,14 +370,16 @@ public:
|
||||
std::numeric_limits<uint64_t>::max();
|
||||
}
|
||||
};
|
||||
std::list<ContState> layers;
|
||||
// from latest to earliest
|
||||
using layers_t = std::vector<ContState>;
|
||||
layers_t layers;
|
||||
|
||||
struct StackState {
|
||||
const uint64_t next;
|
||||
const uint64_t size;
|
||||
};
|
||||
std::list<std::pair<std::list<ContState>::iterator, StackState> > stack;
|
||||
std::list<ContState>::iterator current;
|
||||
std::stack<std::pair<layers_t::iterator, StackState> > stack;
|
||||
layers_t::iterator current;
|
||||
|
||||
explicit iterator(ObjectDesc &obj) :
|
||||
pos(0),
|
||||
|
Loading…
Reference in New Issue
Block a user