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

FX Coudert fxcoudert@gmail.com
Sat Nov 17 02:11:00 GMT 2007


> Please call the variable written_commons, otherwise the name  
> written_common is overloaded with different meanings.

OK.

>> +  /* 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;
}
gfc_common_head;


Thanks,
FX



More information about the Fortran mailing list