How to avoid throwing an exceptions for a built-in function?

ag0aep6g via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 12 03:47:04 PDT 2017


On 05/12/2017 10:32 AM, k-five wrote:
> Interesting! I was worried about performance and for that I did not want
> to use try-catch.
> So (isNumberic) is a good solution.
> http://dlang.org/phobos/std_traits.html#isNumeric

If you're doing this for speed, you better be benchmarking. Exceptions 
are slow when they're thrown. But if no exception is being thrown, 
try-catch is probably faster than checking isNumeric beforehand.


More information about the Digitalmars-d-learn mailing list