summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--absl/container/internal/btree.h35
1 files changed, 14 insertions, 21 deletions
diff --git a/absl/container/internal/btree.h b/absl/container/internal/btree.h
index fd7860da..00a9cb13 100644
--- a/absl/container/internal/btree.h
+++ b/absl/container/internal/btree.h
@@ -580,14 +580,12 @@ class btree_node {
using layout_type =
absl::container_internal::Layout<btree_node *, uint32_t, field_type,
slot_type, btree_node *>;
+ using leaf_layout_type = typename layout_type::template WithStaticSizes<
+ /*parent*/ 1,
+ /*generation*/ BtreeGenerationsEnabled() ? 1 : 0,
+ /*position, start, finish, max_count*/ 4>;
constexpr static size_type SizeWithNSlots(size_type n) {
- return layout_type(
- /*parent*/ 1,
- /*generation*/ BtreeGenerationsEnabled() ? 1 : 0,
- /*position, start, finish, max_count*/ 4,
- /*slots*/ n,
- /*children*/ 0)
- .AllocSize();
+ return leaf_layout_type(/*slots*/ n, /*children*/ 0).AllocSize();
}
// A lower bound for the overhead of fields other than slots in a leaf node.
constexpr static size_type MinimumOverhead() {
@@ -619,27 +617,22 @@ class btree_node {
constexpr static size_type kNodeSlots =
kNodeTargetSlots >= kMinNodeSlots ? kNodeTargetSlots : kMinNodeSlots;
+ using internal_layout_type = typename layout_type::template WithStaticSizes<
+ /*parent*/ 1,
+ /*generation*/ BtreeGenerationsEnabled() ? 1 : 0,
+ /*position, start, finish, max_count*/ 4, /*slots*/ kNodeSlots,
+ /*children*/ kNodeSlots + 1>;
+
// The node is internal (i.e. is not a leaf node) if and only if `max_count`
// has this value.
constexpr static field_type kInternalNodeMaxCount = 0;
- constexpr static layout_type Layout(const size_type slot_count,
- const size_type child_count) {
- return layout_type(
- /*parent*/ 1,
- /*generation*/ BtreeGenerationsEnabled() ? 1 : 0,
- /*position, start, finish, max_count*/ 4,
- /*slots*/ slot_count,
- /*children*/ child_count);
- }
// Leaves can have less than kNodeSlots values.
- constexpr static layout_type LeafLayout(
+ constexpr static leaf_layout_type LeafLayout(
const size_type slot_count = kNodeSlots) {
- return Layout(slot_count, 0);
- }
- constexpr static layout_type InternalLayout() {
- return Layout(kNodeSlots, kNodeSlots + 1);
+ return leaf_layout_type(slot_count, 0);
}
+ constexpr static auto InternalLayout() { return internal_layout_type(); }
constexpr static size_type LeafSize(const size_type slot_count = kNodeSlots) {
return LeafLayout(slot_count).AllocSize();
}