Skip to content

Commit

Permalink
Update immer to c89819df92191d6969a6a22c88c72943b8e25016 (#2626)
Browse files Browse the repository at this point in the history
  • Loading branch information
UdjinM6 authored Jan 14, 2019
1 parent a22f1bf commit a05eeb2
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 116 deletions.
2 changes: 1 addition & 1 deletion src/immer/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class array
array take_move(std::false_type, size_type elems)
{ return impl_.take(elems); }

impl_t impl_ = impl_t::empty;
impl_t impl_ = impl_t::empty();
};

} /* namespace immer */
17 changes: 9 additions & 8 deletions src/immer/detail/arrays/no_capacity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ struct no_capacity
node_t* ptr;
size_t size;

static const no_capacity empty;
static const no_capacity& empty()
{
static const no_capacity empty_ {
node_t::make_n(0),
0,
};
return empty_;
}

no_capacity(node_t* p, size_t s)
: ptr{p}, size{s}
Expand All @@ -37,7 +44,7 @@ struct no_capacity
}

no_capacity(no_capacity&& other)
: no_capacity{empty}
: no_capacity{empty()}
{
swap(*this, other);
}
Expand Down Expand Up @@ -181,12 +188,6 @@ struct no_capacity
}
};

template <typename T, typename MP>
const no_capacity<T, MP> no_capacity<T, MP>::empty = {
node_t::make_n(0),
0,
};

} // namespace arrays
} // namespace detail
} // namespace immer
19 changes: 10 additions & 9 deletions src/immer/detail/arrays/with_capacity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ struct with_capacity
size_t size;
size_t capacity;

static const with_capacity empty;
static const with_capacity& empty()
{
static const with_capacity empty_ {
node_t::make_n(1),
0,
1
};
return empty_;
}

with_capacity(node_t* p, size_t s, size_t c)
: ptr{p}, size{s}, capacity{c}
Expand All @@ -46,7 +54,7 @@ struct with_capacity
}

with_capacity(with_capacity&& other)
: with_capacity{empty}
: with_capacity{empty()}
{
swap(*this, other);
}
Expand Down Expand Up @@ -285,13 +293,6 @@ struct with_capacity
}
};

template <typename T, typename MP>
const with_capacity<T, MP> with_capacity<T, MP>::empty = {
node_t::make_n(1),
0,
1,
};

} // namespace arrays
} // namespace detail
} // namespace immer
19 changes: 10 additions & 9 deletions src/immer/detail/hamts/champ.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ struct champ
node_t* root;
size_t size;

static const champ empty;
static const champ& empty()
{
static const champ empty_ {
node_t::make_inner_n(0),
0,
};
return empty_;
}

champ(node_t* r, size_t sz)
: root{r}, size{sz}
Expand All @@ -47,7 +54,7 @@ struct champ
}

champ(champ&& other)
: champ{empty}
: champ{empty()}
{
swap(*this, other);
}
Expand Down Expand Up @@ -387,7 +394,7 @@ struct champ
node->values()[!offset]);
} else {
assert(shift == 0);
return empty.root->inc();
return empty().root->inc();
}
}
}
Expand Down Expand Up @@ -463,12 +470,6 @@ struct champ
}
};

template <typename T, typename H, typename Eq, typename MP, bits_t B>
const champ<T, H, Eq, MP, B> champ<T, H, Eq, MP, B>::empty = {
node_t::make_inner_n(0),
0,
};

} // namespace hamts
} // namespace detail
} // namespace immer
7 changes: 4 additions & 3 deletions src/immer/detail/rbts/operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <immer/config.hpp>
#include <immer/heap/tags.hpp>
#include <immer/detail/util.hpp>
#include <immer/detail/rbts/position.hpp>
#include <immer/detail/rbts/visitor.hpp>

Expand Down Expand Up @@ -1959,9 +1960,9 @@ struct concat_merger_mut
from_data + from_offset + to_copy,
data + to_offset_);
else
uninitialized_move(from_data + from_offset,
from_data + from_offset + to_copy,
data + to_offset_);
detail::uninitialized_move(from_data + from_offset,
from_data + from_offset + to_copy,
data + to_offset_);
}
to_offset_ += to_copy;
from_offset += to_copy;
Expand Down
37 changes: 19 additions & 18 deletions src/immer/detail/rbts/rbtree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,22 @@ struct rbtree
node_t* root;
node_t* tail;

static const rbtree empty;
static const rbtree& empty()
{
static const rbtree empty_ {
0,
BL,
node_t::make_inner_n(0u),
node_t::make_leaf_n(0u)
};
return empty_;
}

template <typename U>
static auto from_initializer_list(std::initializer_list<U> values)
{
auto e = owner_t{};
auto result = rbtree{empty};
auto result = rbtree{empty()};
for (auto&& v : values)
result.push_back_mut(e, v);
return result;
Expand All @@ -51,7 +60,7 @@ struct rbtree
static auto from_range(Iter first, Iter last)
{
auto e = owner_t{};
auto result = rbtree{empty};
auto result = rbtree{empty()};
for (; first != last; ++first)
result.push_back_mut(e, *first);
return result;
Expand All @@ -60,7 +69,7 @@ struct rbtree
static auto from_fill(size_t n, T v)
{
auto e = owner_t{};
auto result = rbtree{empty};
auto result = rbtree{empty()};
while (n --> 0)
result.push_back_mut(e, v);
return result;
Expand All @@ -79,7 +88,7 @@ struct rbtree
}

rbtree(rbtree&& other)
: rbtree{empty}
: rbtree{empty()}
{
swap(*this, other);
}
Expand Down Expand Up @@ -235,7 +244,7 @@ struct rbtree
{
if (size != other.size) return false;
if (size == 0) return true;
return (size <= branches<B>
return (size <= branches<BL>
|| make_regular_sub_pos(root, shift, tail_offset()).visit(
equals_visitor{}, other.root))
&& make_leaf_sub_pos(tail, tail_size()).visit(
Expand Down Expand Up @@ -415,7 +424,7 @@ struct rbtree
{
auto tail_off = tail_offset();
if (new_size == 0) {
return empty;
return empty();
} else if (new_size >= size) {
return *this;
} else if (new_size > tail_off) {
Expand All @@ -434,7 +443,7 @@ struct rbtree
assert(new_root->check(new_shift, new_size - get<2>(r)));
return { new_size, new_shift, new_root, new_tail };
} else {
return { new_size, BL, empty.root->inc(), new_tail };
return { new_size, BL, empty().root->inc(), new_tail };
}
}
}
Expand All @@ -444,7 +453,7 @@ struct rbtree
auto tail_off = tail_offset();
if (new_size == 0) {
// todo: more efficient?
*this = empty;
*this = empty();
} else if (new_size >= size) {
return;
} else if (new_size > tail_off) {
Expand All @@ -471,7 +480,7 @@ struct rbtree
root = new_root;
shift = new_shift;
} else {
root = empty.root->inc();
root = empty().root->inc();
shift = BL;
}
dec_leaf(tail, size - tail_off);
Expand Down Expand Up @@ -515,14 +524,6 @@ struct rbtree
}
};

template <typename T, typename MP, bits_t B, bits_t BL>
const rbtree<T, MP, B, BL> rbtree<T, MP, B, BL>::empty = {
0,
BL,
node_t::make_inner_n(0),
node_t::make_leaf_n(0)
};

} // namespace rbts
} // namespace detail
} // namespace immer
Loading

0 comments on commit a05eeb2

Please sign in to comment.