[Issue 18541] comparison `==` of two typeid() should always be rewritten as a "is"
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Mar 2 11:13:33 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18541
Jonathan M Davis <issues.dlang at jmdavisProg.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |issues.dlang at jmdavisProg.co
| |m
--- Comment #7 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
(In reply to Basile B. from comment #6)
> (In reply to Steven Schveighoffer from comment #5)
> > Note that == will shortcut and return true if the two instances are the same
> > object.
>
> With someone yesterday we have verified that it's really not the case. In a
> specific hotspot, using "==" instead of "is" made something running in 7
> minutes instead of 4 !
>
> This is exactly why i opened this issue but unfortunately i understand now
> that it's not applicable, we just take care to use "is".
The very first thing in the implementation of the free function opEquals is
if (lhs is rhs) return true;
So, it most definitely shortcuts. Now, that doesn't mean that it's as
efficient, since unless it's inlined, you're calling a function that isn't
called if you use is directly, but the shortcut definitely happens.
--
More information about the Digitalmars-d-bugs
mailing list