This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ edge_iterator (was: Re: [SH] PR 53976 - Add RTL pass to eliminate clrt, sett insns)
- From: Oleg Endo <oleg dot endo at t-online dot de>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Trevor Saunders <tsaunders at mozilla dot com>, gcc-patches at gcc dot gnu dot org
- Date: Sat, 14 Dec 2013 13:54:57 +0100
- Subject: Re: C++ edge_iterator (was: Re: [SH] PR 53976 - Add RTL pass to eliminate clrt, sett insns)
- Authentication-results: sourceware.org; auth=none
- References: <1384975779 dot 2438 dot 119 dot camel at yam-132-YW-E178-FTW> <CABu31nPbcThrjzPN49E=VO3BrZjz5noaE95gjj-vx=0ikPj6+g at mail dot gmail dot com> <1386784057 dot 2455 dot 73 dot camel at yam-132-YW-E178-FTW> <20131212081349 dot GA1708 at tsaunders-iceball dot corp dot tor1 dot mozilla dot com> <1386968457 dot 2455 dot 129 dot camel at yam-132-YW-E178-FTW> <0b879b47-5e17-462e-9e58-68fb0268818c at email dot android dot com>
On Sat, 2013-12-14 at 10:19 +0100, Richard Biener wrote:
> Oleg Endo <oleg.endo@t-online.de> wrote:
> >On Thu, 2013-12-12 at 03:13 -0500, Trevor Saunders wrote:
> >> On Wed, Dec 11, 2013 at 06:47:37PM +0100, Oleg Endo wrote:
> >> > On Thu, 2013-11-21 at 00:04 +0100, Steven Bosscher wrote:
> >> > > Declaring the edge_iterator inside the for() is not a good
> >argument
> >> > > against FOR_EACH_EDGE. Of course, brownie points are up for grabs
> >for
> >> > > the brave soul daring enough to make edge iterators be proper C++
> >> > > iterators... ;-)
> >>
> >> so, as a first question why do we have a special edge iterator at
> >all? it
> >> seems like we could just have a vec iterator and use that removing a
> >> bunch of indirection that seems pretty useless.
> >
> >I don't know why it's there. Looks like a remainder from the pre-C++
> >code, as the conversion is being done step by step.
>
> The fact that we iterate over a vector is an implementation detail that should be hidden.
Yep. Actually there are two implementation details:
> The fact that we iterate over a vector
1) ^^^^^^^ 2) ^^^^^^
This is addressed in the STL by splitting iterators and algorithms.
Whether a specialized/optimized version of an algorithm is available
when used with a particular iterator type (or inherently container type)
becomes an implementation detail and does require changes to code that
uses algorithms or iterators.
Cheers,
Oleg