Thoughts about D

Walter Bright newshound2 at digitalmars.com
Thu Nov 30 03:29:56 UTC 2017


On 11/29/2017 7:15 PM, Jonathan M Davis wrote:
> I wouldn't have expected assertions to cost much more than however much it
> costs to evaluate the expression being asserted unless the assertion fails.
> Now, even that can slow down a program a fair bit, depending on what's being
> asserted and how many assertions there are, but it's not something that I
> would have expected to vary particular between C and D. It doesn't surprise
> me that the generated code would be larger than you'd get for the same
> assertions in C because how assertions are handled when they fail is quite
> different, but I would expect the assertions themselves to cost about the
> same in terms of performance as long as they don't fail. What's going on
> that's making them so much worse?

The code *size* causes problems because it pushes the executing code out of the 
cache. Another issue (I should check this again) was doing null checks on member 
function calls, which is not necessary since if they're null it'll seg fault.



More information about the Digitalmars-d mailing list