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]

Re: Use C++11 direct init in __debug::forward_list


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.


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