dmd foreach loops throw exceptions on invalid UTF sequences, use replacementDchar instead

deadalnix deadalnix at gmail.com
Fri Nov 5 14:06:55 UTC 2021


On Friday, 5 November 2021 at 13:25:06 UTC, Andrei Alexandrescu 
wrote:
> On 2021-11-04 20:40, Walter Bright wrote:
>> On 11/4/2021 12:51 AM, Elronnd wrote:
>>> In the hot path it's the same speed.
>> 
>> C++ sold everyone the myth that exceptions not thrown are zero 
>> cost. This has been thoroughly debunked, though the myth 
>> persists :-(
>
> I've been doing a fair amount of benchmarking for 
> https://amazon.com/Embracing-Modern-Safely-John-Lakos/dp/0137380356 and surprisingly enough the myth holds true in most cases.

It really depends on the exact specification of the myth.

You get executable bigger by about 20%, and some constructs such 
as ref counted smart pointer become harder to optimize, but 
indeed, the cost when you don't throw in term of runtime isn't 
remotely as high as people seems to think.


More information about the Digitalmars-d mailing list