Implicit integer casting
Steven Schveighoffer
schveiguy at yahoo.com
Mon Mar 19 04:50:25 PDT 2012
On Sun, 18 Mar 2012 22:46:56 -0400, James Miller <james at aatch.net> wrote:
>>> Another thing I have noticed, is that that compared to a cast,
>>> to!<type> is incredibly slow. Most of the time it doesn't matter, but
>>> I was doing some work with noise generation, and found that casting
>>> the floats to integers was an order of magnitude faster than using
>>> to!int.
>>
>>
>> There's a check involved, and possibly inlining doesn't make it for
>> whatever
>> reason.
>>
>> Andrei
>
> Oh, I wasn't complaining, more just making an observation that the
> safe to!<type> is slower than an unsafe cast. Probably obvious, but
> worth mentioning nonetheless.
Given the utility of D's templates, the achievable goal should be to make
it equivalent. It's worth pointing out, and should be filed as a bug.
I'd bet that it was lack of inlining, possibly due to usage of enforce
(haven't looked at the code).
-Steve
More information about the Digitalmars-d
mailing list