[fortran,patch] Don't write common more than once in a module file (PR 30285)
Tobias Schlüter
tobias.schlueter@physik.uni-muenchen.de
Sat Nov 10 18:02:00 GMT 2007
FX Coudert wrote:
> @@ -3767,30 +3767,50 @@ gfc_check_access (gfc_access specific_ac
> }
>
>
> -/* Write a common block to the module. */
> +struct written_common
> +{
> + const char *name, *label;
> + struct written_common *next;
> +};
> +
> +static struct written_common *written_common;
Please call the variable written_commons, otherwise the name
written_common is overloaded with different meanings.
> + /* Check if we've already output this common. */
> + for (w = written_common; w; w = w->next)
> + if (strcmp (w->name, name) == 0 && strcmp (w->label, label) == 0)
> + return;
This is quadratic in the numbers of commons in a module. Please make
written_common a balanced tree (such as our BBT_HEADER & associates,
this would leave us with O(N log(N)) complexity) or a hashtable (leaving
us with O(N) or something like that). A non-algorithmic speedup would
be comparing the pointers directly, since as they are allocated strings
they're guaranteed to be different strings if they point to different
locations.
Other than that, this looks ok.
Thanks,
- Tobi
More information about the Fortran
mailing list