This is the mail archive of the 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]

Re: unordered containers: reuse nodes on assignment

On 4 July 2013 21:54, François Dumont wrote:
> And about the patch itself, is it ok ?

Yes, that latest patch is OK, thanks.

It's made me think about the design a bit more though ...

I've been a little uncomfortable for some time with the number of
template parameters that are needed everywhere in hashtable_policy.h.
In most cases they seem necessary, but does the _ReuseOrAllocNode
template really need 10 template parameters?  Couldn't it just be
passed the relevant _Hashtable type? Unfortunately with the current
design it does seem necessary to know the full _Hashtable type, even
though the functionality only really depends on the allocator type
(and node and value types, but they can be obtained from the
allocator.)  That means if I instantiate unordered_set<T, H, P, A> and
unordered_set<T, H2, P2, A> the compiler has to instantiate two
different specializations of _ReuseOrAllocNode (and other code in
_Hashtable) even though it doesn't care about the two function
objects, and the executable is larger.

Would it be possible to separate _M_node_allocator, _M_allocate_node,
_M_deallocate_nodes and _M_deallocate_node into a separate base class
of _Hashtable, and have _ReuseOrAllocNode only depend on that?  That
would allow unordered_set<T, H, P, A> and unordered_set<T, H2, P2, A>
to share more code.

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