[patch] basic-block.h: Speed up FOR_EACH_EDGE.

Jeffrey A Law law@redhat.com
Fri Mar 11 20:08:00 GMT 2005


On Fri, 2005-03-11 at 11:05 -0800, Zack Weinberg wrote:
> >> Plus, having to declare two things, an iterator object and this length
> >> variable, seems to tedious.  Whenever I see an iterator, I expect that
> >> all I have to do is to declare an iterator obejct, give it to
> >> FOR_EACH_EDGE, and everything magically works (as long as I don't mess
> >> with a container that I am iterating over).
> > Agreed.  However, that model has the fundamental problem that you're
> > putting a field into the iterator object that we make absolutely no
> > attempt to keep up-to-date, which can lead to serious confusion.
> 
> Can the iterator be made an opaque object from the user's point of
> view?  (up to having to have the structure definition visible for
> inlining purposes) Then it's nobody's business what is inside, and it
> ceases to matter whether the field is up-to-date.
I think this is what Kazu wants to do via documenting the convention
that the field is not kept up-to-date.

I can't see any way to hide it completely using macros without
making debugging the body of the FOR_EACH_EDGE impossible, which
I would consider unacceptable.

We can't use C99 features.

I think that leaves us with just Kazu's comments or passing in another
variable to the iterator.

I don't like either choice :(  Let's go with Kazu's as it has less
disruption.

jeff




More information about the Gcc-patches mailing list