[phobos] std.algorithm.sort slow as molasses

Jonathan M Davis jmdavisprog at gmail.com
Fri Jul 2 15:10:06 PDT 2010


On Friday, July 02, 2010 13:57:33 David Simcha wrote:

> bool evalPred(alias pred)(uint num) {
>     // This line is to make sure that this function doesn't get inlined
> into // main.  DMD doesn't inline functions that could throw.
>     if(num == uint.max) {
>         throw new Exception("");
>     }
> 
>     return pred(num);
> }

DMD doesn't inline functions that could throw? Isn't that rather restrictive? 
I'm assuming that that's functions with an actual throw statement rather than 
all functions that aren't nothrow, since that would _really_ be restrictive. But 
still, you could have a really small function that threw if a condition failed 
but otherwise just returned a value, and I would have thought that that would be 
worth inlining. I'm far from an expert once you're dealing with stuff that low-
level, so there could be a very good reason that functions that could throw 
aren't inlined, but it does strike me as rather restrictive if you can't inline 
such functions.

- Jonathan M Davis


More information about the phobos mailing list