[btree] factor out inc_children

This commit is contained in:
Joe Thornber 2013-06-20 12:17:16 +01:00
parent a2e51062e3
commit c8a5d0753d
2 changed files with 20 additions and 11 deletions

View File

@ -413,6 +413,10 @@ namespace persistent_data {
btree_detail::node_location const &loc, btree_detail::node_location const &loc,
block_address b) const; block_address b) const;
template <typename ValueTraits2, typename RefCounter>
void inc_children(btree_detail::shadow_spine &spine,
RefCounter &leaf_rc);
typename persistent_data::transaction_manager::ptr tm_; typename persistent_data::transaction_manager::ptr tm_;
bool destroy_; bool destroy_;
block_address root_; block_address root_;

View File

@ -695,17 +695,7 @@ namespace persistent_data {
for (;;) { for (;;) {
inc = spine.step(block); inc = spine.step(block);
inc_children<ValueTraits>(spine, leaf_rc);
// FIXME: factor out
{
node_ref<uint64_traits> nr = spine.template get_node<uint64_traits>();
if (nr.get_type() == INTERNAL)
nr.inc_children(internal_rc_);
else {
node_ref<ValueTraits> leaf = spine.template get_node<ValueTraits>();
leaf.inc_children(leaf_rc);
}
}
// patch up the parent to point to the new shadow // patch up the parent to point to the new shadow
if (spine.has_parent()) { if (spine.has_parent()) {
@ -820,6 +810,21 @@ namespace persistent_data {
v.visit_leaf(loc, ov); v.visit_leaf(loc, ov);
} }
} }
template <unsigned Levels, typename _>
template <typename ValueTraits, typename RefCounter>
void
btree<Levels, _>::inc_children(btree_detail::shadow_spine &spine, RefCounter &leaf_rc)
{
node_ref<uint64_traits> nr = spine.template get_node<uint64_traits>();
if (nr.get_type() == INTERNAL)
nr.inc_children(internal_rc_);
else {
node_ref<ValueTraits> leaf = spine.template get_node<ValueTraits>();
leaf.inc_children(leaf_rc);
}
}
} }
//---------------------------------------------------------------- //----------------------------------------------------------------