@@ -255,8 +255,7 @@ class cache_impl
255255 if (m_cached_nodes.empty ()){
256256 mp_node_pool->allocate_nodes (m_max_cached_nodes/2 , m_cached_nodes);
257257 }
258- void *ret = ipcdetail::to_raw_pointer (m_cached_nodes.pop_front ());
259- return ret;
258+ return ipcdetail::to_raw_pointer (m_cached_nodes.pop_front ());
260259 }
261260
262261 void cached_allocation (size_type n, multiallocation_chain &chain)
@@ -540,14 +539,14 @@ class node_pool_allocation_impl
540539 if (size_overflows<sizeof (T)>(count)){
541540 throw bad_alloc ();
542541 }
543- else if (Version == 1 && count == 1 ){
544- return pointer (static_cast <value_type*>
545- (pool->allocate_node ()));
546- }
547- else {
548- return pointer (static_cast <value_type*>
549- (pool->get_segment_manager ()->allocate_aligned (count*sizeof (T), boost::container::dtl::alignment_of<T>::value)));
542+
543+ BOOST_IF_CONSTEXPR (Version == 1 )
544+ if (count == 1 ){
545+ return pointer (static_cast <value_type*>(pool->allocate_node ()));
550546 }
547+
548+ return pointer (static_cast <value_type*>
549+ (pool->get_segment_manager ()->allocate_aligned (count*sizeof (T), boost::container::dtl::alignment_of<T>::value)));
551550 }
552551
553552 // !Deallocate allocated memory. Never throws
@@ -556,10 +555,14 @@ class node_pool_allocation_impl
556555 (void )count;
557556 typedef typename node_pool<0 >::type node_pool_t ;
558557 node_pool_t *pool = node_pool<0 >::get (this ->derived ()->get_node_pool ());
559- if (Version == 1 && count == 1 )
558+
559+ BOOST_IF_CONSTEXPR (Version == 1 )
560+ if (count == 1 ){
560561 pool->deallocate_node (ipcdetail::to_raw_pointer (ptr));
561- else
562- pool->get_segment_manager ()->deallocate ((void *)ipcdetail::to_raw_pointer (ptr));
562+ return ;
563+ }
564+
565+ pool->get_segment_manager ()->deallocate ((void *)ipcdetail::to_raw_pointer (ptr));
563566 }
564567
565568 // !Allocates just one object. Memory allocated with this function
@@ -729,30 +732,29 @@ class cached_allocator_impl
729732 BOOST_INTERPROCESS_NODISCARD
730733 pointer allocate (size_type count)
731734 {
732- void * ret;
733735 if (size_overflows<sizeof (T)>(count)){
734736 throw bad_alloc ();
735737 }
736- else if (Version == 1 && count == 1 ){
737- ret = m_cache.cached_allocation ();
738- }
739- else {
740- ret = this ->get_segment_manager ()->allocate_aligned
741- (count*sizeof (T), boost::container::dtl::alignment_of<T>::value);
738+
739+ BOOST_IF_CONSTEXPR (Version == 1 )
740+ if (count == 1 ){
741+ return pointer (static_cast <T*>(m_cache.cached_allocation ()));
742742 }
743- return pointer (static_cast <T*>(ret));
743+
744+ return pointer (static_cast <value_type*>
745+ (this ->get_segment_manager ()->allocate_aligned (count*sizeof (T), boost::container::dtl::alignment_of<T>::value)));
744746 }
745747
746748 // !Deallocate allocated memory. Never throws
747749 void deallocate (const pointer &ptr, size_type count)
748750 {
749751 (void )count;
750- if (Version == 1 && count == 1 ){
752+ BOOST_IF_CONSTEXPR (Version == 1 )
753+ if (count == 1 ) {
751754 m_cache.cached_deallocation (ipcdetail::to_raw_pointer (ptr));
755+ return ;
752756 }
753- else {
754- this ->get_segment_manager ()->deallocate ((void *)ipcdetail::to_raw_pointer (ptr));
755- }
757+ this ->get_segment_manager ()->deallocate ((void *)ipcdetail::to_raw_pointer (ptr));
756758 }
757759
758760 // !Allocates just one object. Memory allocated with this function
0 commit comments