https://issues.dlang.org/show_bug.cgi?id=19975
Issue ID: 19975
Summary: object.opEquals(Object lhs, Object rhs) can skip
typeid comparison when !lhs.opEquals(rhs)
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: druntime
Assignee: [email protected]
Reporter: [email protected]
Current:
---
bool opEquals(Object lhs, Object rhs)
{
if (lhs is rhs) return true;
if (lhs is null || rhs is null) return false;
if (typeid(lhs) is typeid(rhs) ||
!__ctfe && typeid(lhs).opEquals(typeid(rhs)))
{
return lhs.opEquals(rhs);
}
else
{
return lhs.opEquals(rhs) && rhs.opEquals(lhs);
}
}
---
Suggested:
---
bool opEquals(Object lhs, Object rhs)
{
if (lhs is rhs) return true;
if (lhs is null || rhs is null) return false;
if (!lhs.opEquals(rhs)) return false;
if (typeid(lhs) is typeid(rhs) ||
!__ctfe && typeid(lhs).opEquals(typeid(rhs)))
{
return true;
}
else
{
return rhs.opEquals(lhs);
}
}
---
--