Old problem with performance
Kagamin
spam at here.lot
Mon Feb 9 01:35:21 PST 2009
Weed Wrote:
> The code on C++ is also approximately in 6 times faster a code with
> classes on D. (I do not give an example on C++ because classes on C++
> work just as structures in D.)
> class C {
> int i;
> real[5] unused; // to prevent returning this object in registers
>
> C opAdd( C src ) {
> auto ret = new C;
> ret.i = i + src.i;
> return ret;
> }
> }
Well, D class code here is not equivalent to C++ class code. D code has more features, namely, it's polymorphic: C.opAdd is able to work with classes, derived from C, while corresponding C++ code is unable to do so. If you can't use polymorphism, why do you use classes?
More information about the Digitalmars-d
mailing list