This is the mail archive of the
mailing list for the GCC project.
Re: [fortran,patch] Don't write common more than once in a module file (PR 30285)
- From: FX Coudert <fxcoudert at gmail dot com>
- To: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- Cc: "fortran at gcc dot gnu dot org List" <fortran at gcc dot gnu dot org>, gcc-patches list <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 17 Nov 2007 00:53:23 +0000
- Subject: Re: [fortran,patch] Don't write common more than once in a module file (PR 30285)
- References: <26954C8E-C987-4CD4-9887-310B6D00F004@gmail.com> <4735D4C2.firstname.lastname@example.org>
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)
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).
Hum... Don't hurt me, I'm a mere chemist! :)
I'll look into it, and post an updated patch. Until then, though:
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.
Hum, they're static buffers actually, so I don't think I can do that,
typedef struct gfc_common_head
char use_assoc, saved, threadprivate;
char name[GFC_MAX_SYMBOL_LEN + 1];
struct gfc_symbol *head;
char binding_label[GFC_MAX_BINDING_LABEL_LEN + 1];