[RFC] Long standing small inefficiency in std::deque
Paolo Carlini
pcarlini@suse.de
Mon Nov 12 15:21:00 GMT 2007
Hi,
I'm working on the experimental C++0x changes to deque and noticed what
seems apparently a long standing small inefficiency, easy to fix (*).
I'm talking about push_back / push_front.
When there is no free space, _M_push_back_aux (_M_push_front_aux) is
called, which in turn, first does a copy of the new value to a
temporary. That copy seems to me not necessary. In fact, before the next
allocator::construct, _M_reserve_map_at_back (_M_reserve_map_at_front)
is called but the actual deque elements are *not* moved, only, possibly,
the map of pointers to nodes (iterators can also be invalidated but
push_back / push_front do not have any iterator argument). Thus I mean
to just scrap that copy (to value_type __t_copy). Can you see any gap in
my reasoning? To be sure, I'll wait a while, will commit first the C++0x
changes *without* this tweak which can be applied also to the normal
C++03 implementation.
Thanks,
Paolo.
(*) I know there are many other ABI-breaking and not ABI-breaking
opportunities for improvement, let's start somewhere...
More information about the Libstdc++
mailing list