This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [Patch, libstdc++/64584, libstdc++/64585] Clear basic_regex after imbue and make assign exception tolerant
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: Jonathan Wakely <jwakely at redhat dot com>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Fri, 16 Jan 2015 14:34:29 +0100 (CET)
- Subject: Re: [Patch, libstdc++/64584, libstdc++/64585] Clear basic_regex after imbue and make assign exception tolerant
- Authentication-results: sourceware.org; auth=none
- References: <CAG4ZjNmMbv4c-bix8VZV8CrudrZZOgMas3cKPhLwoiTnPOMUCA at mail dot gmail dot com> <20150116121217 dot GA3360 at redhat dot com>
- Reply-to: libstdc++ <libstdc++ at gcc dot gnu dot org>
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