This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Simplify allocator usage in unordered containers


While fixing PR 81891 I noticed that _Hashtable always creates a
__value_alloc_type for constructing and destroying the elements, which
is unnecessary. https://wg21.link/lwg2218 confirmed that.

We can avoid constructing new allocators just for these calls and can
call them directly on the stored allocator.

	* include/bits/hashtable_policy.h (_ReuseOrAllocNode): Remove
	__value_alloc_type and __value_alloc_traits typedefs.
	(_ReuseOrAllocNode::operator()): Call construct and destroy on the
	node allocator.
	(_Hashtable_alloc): Simplify __value_alloc_traits typedef.
	(_Hashtable_alloc<_NodeAlloc>::_M_allocate_node(_Args&&...)): Call
	construct on the node allocator.
	(_Hashtable_alloc<_NodeAlloc>::_M_deallocate_node(__node_type*)): Call
	destroy on the node allocator.

Tested powerpc64le-linux, committed to trunk.

Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]