Use C++11 direct init in __debug::forward_list
Jonathan Wakely
jwakely@redhat.com
Mon Oct 15 09:58:00 GMT 2018
On 11/10/18 22:46 +0200, François Dumont wrote:
>This patch makes extensive use of C++11 direct init in
>__debug::forward_list.
>
>Doing so I also try to detect useless creation of safe iterators in
>debug implementation. In __debug::forward_list there are severals but
>I wonder if it is worth fixing those. Most of them are like this:
>
>Â Â Â Â Â void
>Â Â Â Â Â splice_after(const_iterator __pos, forward_list& __list)
>Â Â Â Â Â { splice_after(__pos, std::move(__list)); }
>
>__pos is copied.
>
>Do you think I shouldn't care, gcc will optimize it ?
I think the _Safe_iterator construction/destruction is too complex to
be optimised away (it locks a mutex, doesn't it?).
Normally I'd say you could use std::move(__pos) but IIRC that's even
more expensive than a copy, as it locks two mutexes.
>I wonder if it would be ok in debug implementation to use this kind of
>signature:
>
>void splice_after(const const_iterator& __pos, forward_list& __list)
>
>Iterator taken as rvalue reference ?
>
>I guess it is not Standard conformant so not correct but maybe I could
>add a private _M_splice_after with this signature.
It doesn't seem worthwhile to me.
More information about the Libstdc++
mailing list