Why is this D code slower than C++?
%u
u at infearof.spm
Thu Jan 18 00:35:01 PST 2007
Bill Baxter Wrote:
> D still not as fast as the C++, but close.
I refuse to analyze this any further.
On comparing the implementations of Primary, I noticed, that the OP has introduced a constructor which executes "new Material". There is no "new" in the cpp-version of Primary but a "SetMaterial" function.
On deleting the new expression in the D-version an exception was raised on executing the newly compiled binary.
Astonishingly grepping over the .cpp and .h -files with agent ransack no calls of "SetMaterial" were delivered---but "GetMaterial" is called---which uses the unset "Material" pointer. :-(
Conclusion: at least one of the following is true
1) I have near to no ability to understand c++
2) the c++-version is lucky to run at all
In case of 2) the OP has silently changed the algorithm on porting to D.
More information about the Digitalmars-d-learn
mailing list