long compile time 2.023 (few lines of code)

Steven Schveighoffer schveiguy at yahoo.com
Fri Jan 23 14:59:54 PST 2009


"Saaa" wrote
> The following code takes too long to compile (I kill link.exe to stop it)
> dmd 2.023 bud -full - cleanup
>
> --
> module project.main;
>
> import project.bug;
>
> void main()
> {
>
> }
> --
> module project.bug;
>
> struct Struct
> {
> uint number;
> int[6] array;
> byte[9] array2;
> }
> Struct structs[1_000_000];
> --
>
> Multiple variations on the struct seem to have the long compile time 
> effect.. allignment problem?

allocating 40MB of static data seems a bit excessive.

1. Your exectuable is probably going to be 40MB (not sure)
2. allocating on the heap is probably going to be faster than this, as the 
OS would not have to read 40MB of static data from the disk.

Is there a reason why you want to do it this way instead of:

Struct[] structs;
static this
{
   structs = new Struct[1_000_000];
}

-Steve 




More information about the Digitalmars-d-learn mailing list