Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slightly tweak implementation of empty collection nodes #189

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions immer/detail/hamts/champ.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ struct champ
node_t* root;
size_t size;

static node_t* empty()
static node_t*& empty()
{
static const auto node = node_t::make_inner_n(0);
return node->inc();
static auto node = node_t::make_inner_n(0);
node->inc();
return node;
}

champ(node_t* r, size_t sz = 0)
Expand Down
14 changes: 8 additions & 6 deletions immer/detail/rbts/rrbtree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,18 @@ struct rrbtree
ipow((size_t{1} << B) - 2, (S - BL) / B);
}

static node_t* empty_root()
static node_t*& empty_root()
{
static const auto empty_ = node_t::make_inner_n(0u);
return empty_->inc();
static auto empty_ = node_t::make_inner_n(0u);
empty_->inc();
return empty_;
}

static node_t* empty_tail()
static node_t*& empty_tail()
{
static const auto empty_ = node_t::make_leaf_n(0u);
return empty_->inc();
static auto empty_ = node_t::make_leaf_n(0u);
empty_->inc();
return empty_;
}

template <typename U>
Expand Down