[btree_damage_visitor] some tweaks to stop constructing so many btree_paths.
This commit is contained in:
parent
a99d6896a8
commit
74de9a1a94
@ -86,22 +86,25 @@ namespace persistent_data {
|
|||||||
class path_tracker {
|
class path_tracker {
|
||||||
public:
|
public:
|
||||||
// returns the old path if the tree has changed.
|
// returns the old path if the tree has changed.
|
||||||
boost::optional<btree_path> next_path(btree_path const &p) {
|
btree_path const *next_path(btree_path const &p) {
|
||||||
if (p != path_) {
|
if (p != current_path()) {
|
||||||
btree_path tmp(path_);
|
if (paths_.size() == 2)
|
||||||
path_ = p;
|
paths_.pop_front();
|
||||||
return boost::optional<btree_path>(tmp);
|
|
||||||
|
paths_.push_back(p);
|
||||||
|
|
||||||
|
return &paths_.front();
|
||||||
}
|
}
|
||||||
|
|
||||||
return boost::optional<btree_path>();
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
btree_path const ¤t_path() const {
|
btree_path const ¤t_path() const {
|
||||||
return path_;
|
return paths_.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
btree_path path_;
|
std::list<btree_path> paths_;
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
@ -189,11 +192,12 @@ namespace persistent_data {
|
|||||||
private:
|
private:
|
||||||
void visit_values(btree_path const &path,
|
void visit_values(btree_path const &path,
|
||||||
node_ref<ValueTraits> const &n) {
|
node_ref<ValueTraits> const &n) {
|
||||||
|
btree_path p2(path);
|
||||||
unsigned nr = n.get_nr_entries();
|
unsigned nr = n.get_nr_entries();
|
||||||
for (unsigned i = 0; i < nr; i++) {
|
for (unsigned i = 0; i < nr; i++) {
|
||||||
btree_path p2(path);
|
|
||||||
p2.push_back(n.key_at(i));
|
p2.push_back(n.key_at(i));
|
||||||
value_visitor_.visit(p2, n.value_at(i));
|
value_visitor_.visit(p2, n.value_at(i));
|
||||||
|
p2.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,7 +431,7 @@ namespace persistent_data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void update_path(btree_path const &path) {
|
void update_path(btree_path const &path) {
|
||||||
boost::optional<btree_path> old_path = path_tracker_.next_path(path);
|
btree_path const *old_path = path_tracker_.next_path(path);
|
||||||
if (old_path)
|
if (old_path)
|
||||||
// we need to emit any errors that
|
// we need to emit any errors that
|
||||||
// were accrued against the old
|
// were accrued against the old
|
||||||
|
Loading…
Reference in New Issue
Block a user