Remove unneeded priv_index_header_from_block

This commit is contained in:
Ion Gaztañaga
2024-09-18 11:39:33 +02:00
parent 0665fd3f1a
commit d6c4649870
3 changed files with 18 additions and 35 deletions

View File

@@ -129,21 +129,11 @@ struct block_header
unsigned short name_length() const
{ return m_num_char; }
size_type name_offset() const
{
return this->value_offset() + get_rounded_size(size_type(m_value_bytes), size_type(sizeof_char()));
}
void *value() const
{
return const_cast<char*>((reinterpret_cast<const char*>(this) + this->value_offset()));
}
size_type value_offset() const
{
return get_rounded_size(size_type(sizeof(block_header)), size_type(m_value_alignment));
}
template<class T>
static block_header *block_header_from_value(T *value)
{
@@ -185,6 +175,17 @@ struct block_header
//Some sanity checks
return hdr;
}
private:
size_type value_offset() const
{
return get_rounded_size(size_type(sizeof(block_header)), size_type(m_value_alignment));
}
size_type name_offset() const
{
return this->value_offset() + get_rounded_size(size_type(m_value_bytes), size_type(sizeof_char()));
}
};
template<class CharT>
@@ -247,15 +248,6 @@ struct intrusive_value_type_impl
intrusive_value_type_impl(){}
block_header_t *get_block_header()
{ return block_header_t::from_first_header(this); }
const block_header_t *get_block_header() const
{ return block_header_t::from_first_header(this); }
static intrusive_value_type_impl *get_intrusive_value_type(block_header_t *hdr)
{ return block_header_t::template to_first_header<intrusive_value_type_impl>(hdr); }
CharType *name() const
{ return get_block_header()->template name<CharType>(); }
@@ -264,6 +256,10 @@ struct intrusive_value_type_impl
void *value() const
{ return get_block_header()->value(); }
private:
const block_header_t *get_block_header() const
{ return block_header_t::from_first_header(this); }
};
template<class CharType>

View File

@@ -113,7 +113,7 @@ struct iunordered_set_index_aux
std::size_t operator()(const compare_key_type&i) const
{
const char_type *beg = i.mp_str,
*end = beg + i.m_len;
*end = beg + i.m_len;
return hash_char_range(beg, end);
}
};

View File

@@ -868,7 +868,7 @@ class segment_manager
typedef IndexType<ipcdetail::index_config<CharT, MemoryAlgorithm> > index_t;
typedef typename index_t::index_data_t index_data_t;
index_data_t *si = priv_index_header_from_block<index_t>(block_header, is_intrusive_t());
index_data_t* si = block_header_t::template to_first_header<index_data_t>(block_header);
return this->priv_generic_named_destroy_impl<T, CharT>(*si, index);
}
@@ -927,7 +927,7 @@ class segment_manager
void *memory;
BOOST_IF_CONSTEXPR(is_node_index_t::value || is_intrusive_t::value){
index_data_t*ihdr = priv_index_header_from_block<index_t>(ctrl_data, is_intrusive_t());
index_data_t*ihdr = block_header_t::template to_first_header<index_data_t>(ctrl_data);
ihdr->~index_data_t();
memory = ihdr;
}
@@ -957,19 +957,6 @@ class segment_manager
return static_cast<block_header_t*>(ipcdetail::to_raw_pointer(it->second.m_ptr));
}
template<class IndexT>
static typename IndexT::index_data_t * priv_index_header_from_block(block_header_t *bh, ipcdetail::true_) //is_intrusive
{
return IndexT::index_data_t::get_intrusive_value_type(bh);
}
template<class IndexT>
static typename IndexT::index_data_t * priv_index_header_from_block(block_header_t* bh, ipcdetail::false_) //!is_intrusive
{
return block_header_t::template to_first_header
<typename IndexT::index_data_t>(bh);
}
//!Generic named new function for
//!named functions
template<class Proxy, class CharT>