Optimization of add_dt_to_dt_list() in resolve.c

Andrew Benson abenson@carnegiescience.edu
Wed May 30 17:01:00 GMT 2018


On Wednesday, May 30, 2018 11:43:58 AM PDT Richard Biener wrote:
> On Tue, May 29, 2018 at 10:24 PM Andrew Benson <abenson@carnegiescience.edu>
> wrote:
> > Yes - definitely possible to remove gfc_dt_list entirely - new patch is
> > attached.
> 
> This looks good to me but it still requires review/ack from fortran people.

Thanks - I'll wait on input from the fortran devs.

> Note another trick commonly used for cyclic lists is to make the "head"
> always present which could be done by making gfc_derived_types a
> gfc_symbol  (non-pointer), chaining to itself.  Then you can elide
> the if (gfc_derived_types) checks and iterate via
> 
> for (gfc_sybol *sym = gfc_derived_types.dt_next; sym != &gfc_derived_types;
> sym = sym->dt_next)
>    ...
> 
> similar appending and removing lose some special cases.
> 
> Having a global gfc_symbol with just one pointer in it used may seem a
> litte ugly though
> (and you have to init it somewhere suitable unless you want to write up a
> huge mostly
> zero static initializer).

That would definitely make the code cleaner. I'll wait on input from the 
fortran devs to see if any of them have an opinion on this - and I'd probably 
need some guidance on where to do the init.

-Andrew

-- 

* Andrew Benson: http://users.obs.carnegiescience.edu/abenson/contact.html

* Galacticus: https://bitbucket.org/abensonca/galacticus



More information about the Fortran mailing list