This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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: [Patch, libstdc++/64584, libstdc++/64585] Clear basic_regex after imbue and make assign exception tolerant


On Fri, 16 Jan 2015, Jonathan Wakely wrote:

Am I missing something here, why are you moving the iterators?

Iterators are cheap to copy, so moving them is not necessary.

(I am not talking about this patch in particular)

Iterators are supposed to be relatively cheap to copy. In practice, that copy doesn't always come for free. When you implemented filesystem iterators, IIRC you had at least a shared_ptr in your iterators, so copying involved some atomic operations and those have a cost (first a direct cost on the system, but also an optimization cost because we can't simplify 5 consecutive copies to only one). I have seen iterators that were even more expensive (and inconvenient to make cheaper). If we can internally reduce the number of copies (move instead, pass by reference, etc), that seems good to me. I wanted to make a pass on predefined_ops.h but didn't find the time.

--
Marc Glisse


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