This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [fortran,patch] Don't write common more than once in a module file (PR 30285)

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).

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, unfortunately :(

typedef struct gfc_common_head
  locus where;
  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];
  int is_bind_c;

Thanks, FX

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]