@@ -33,13 +33,13 @@ CLASS::arrayhead(storage& head, const Link& buckets) NOEXCEPT
3333}
3434
3535TEMPLATE
36- size_t CLASS::size () const NOEXCEPT
36+ inline size_t CLASS::size () const NOEXCEPT
3737{
3838 return file_.size ();
3939}
4040
4141TEMPLATE
42- size_t CLASS::buckets () const NOEXCEPT
42+ inline size_t CLASS::buckets () const NOEXCEPT
4343{
4444 const auto count = position_to_link (size ()).value ;
4545 BC_ASSERT (count < Link::terminal);
@@ -55,8 +55,9 @@ bool CLASS::enabled() const NOEXCEPT
5555TEMPLATE
5656inline Link CLASS::index (size_t key) const NOEXCEPT
5757{
58- if (key >= buckets ())
59- return {};
58+ // buckets a table lock via file.size().
59+ // //if (key >= buckets()) return {};
60+ // //BC_ASSERT_MSG(key < buckets(), "index overflow");
6061
6162 // Put index does not validate, allowing for head expansion.
6263 return putter_index (key);
@@ -70,28 +71,32 @@ inline Link CLASS::putter_index(size_t key) const NOEXCEPT
7071}
7172
7273TEMPLATE
73- bool CLASS::create () NOEXCEPT
74+ bool CLASS::clear () NOEXCEPT
7475{
75- if (is_nonzero (file_.size ()))
76+ const auto ptr = file_.get ();
77+ if (!ptr)
7678 return false ;
7779
78- const auto allocation = link_to_position (initial_buckets_);
79- const auto start = file_.allocate (allocation);
80+ // Retains head size, since head is array not map, and resets body logical
81+ // count to zero, which is picked up in arraymap::reset(). Body file size
82+ // remains unchanged and subject to initialization size at each startup. So
83+ // there is no reduction until restart, which can include config change.
84+ std::fill_n (ptr->data (), size (), system::bit_all<uint8_t >);
85+ return set_body_count (zero);
86+ }
8087
81- // Guards addition overflow in manager_.get (start must be valid).
82- if (start == storage::eof)
88+ TEMPLATE
89+ bool CLASS::create () NOEXCEPT
90+ {
91+ if (is_nonzero (size ()))
8392 return false ;
8493
85- const auto ptr = file_ .get (start);
86- if (!ptr )
94+ // Guards addition overflow in manager_ .get (start must be valid).
95+ if (file_. allocate ( link_to_position (initial_buckets_)) == storage::eof )
8796 return false ;
8897
89- BC_ASSERT_MSG (verify (), " unexpected body size" );
90-
91- // std::memset/fill_n have identical performance (on win32).
92- // //std::memset(ptr->data(), system::bit_all<uint8_t>, size());
93- std::fill_n (ptr->data (), size (), system::bit_all<uint8_t >);
94- return set_body_count (zero);
98+ BC_ASSERT_MSG (verify (), " unexpected head size" );
99+ return clear ();
95100}
96101
97102TEMPLATE
@@ -104,7 +109,7 @@ TEMPLATE
104109bool CLASS::get_body_count (Link& count) const NOEXCEPT
105110{
106111 const auto ptr = file_.get ();
107- if (!ptr || Link::size > file_. size ())
112+ if (!ptr || Link::size > size ())
108113 return false ;
109114
110115 count = array_cast<Link::size>(ptr->data ());
@@ -115,7 +120,7 @@ TEMPLATE
115120bool CLASS::set_body_count (const Link& count) NOEXCEPT
116121{
117122 const auto ptr = file_.get ();
118- if (!ptr || Link::size > file_. size ())
123+ if (!ptr || Link::size > size ())
119124 return false ;
120125
121126 array_cast<Link::size>(ptr->data ()) = count;
0 commit comments