Why is this D code slower than C++?

%u u at infearof.spm
Thu Jan 18 13:22:44 PST 2007


Bradley Smith Wrote:
> What technical documentation would be proper? What would it
> contain?

As always such depends on the requirements of the presumed readers.

If you are able to change your position from the view of the porter to the view of a verifier or freshly introduced maintainer of the port, then you will have an impression of what you would want to look at first.

It is a pity as it stands, that the question for the content of the technical documentation raises at all.

For example the answer you gave to Bill Baxter:

| Because in the C++, GetMaterial returns a pointer. Since other
| objects can use the pointer to change the value of the Material
| contained within a Primitive, the same behavior was used in the D
| code by using a class. If a struct had been used, a copy of Material
| would be returned, and changing the Material would have no effect on
| the Primitive. 

| Also, because GetMaterial is called very often, I assume that making | lots of copies of it would decrease performance. Presumably, that
| is why the C++ code returns a pointer.

would belong into such documentation as well as any other decision that was made during the port.

For example I found a ".dup" in the D-version where there was no copying in the cpp-version. The question raises immediately whether this is done with intent or by accident. Without redundancy provided by technical documentation a careful analysis for the necessity of these four characters has to be undertaken.


More information about the Digitalmars-d-learn mailing list