Structs insted of classes for Performance

Frustrated via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Apr 20 08:03:33 PDT 2014


I know the difference between a struct and a class but I remember 
seeing somewhere that structs are much faster than classes in D 
for some strange reason.

I'm not worried too much about class allocation performance 
because I will try and use classes when they will not be created 
frequently and structs or class reuse when they will be.

So, is the only argument really about performance when creating 
structs vs creating classes or was there some finer detail I 
missed?

Basically that boils down to stack allocation vs heap allocation 
speed? Which, while allocation on the heap shouldn't be too much 
slower than stack, the GC makes it worse?



More information about the Digitalmars-d-learn mailing list