[Issue 19975] New: object.opEquals(Object lhs, Object rhs) can skip typeid comparison when !lhs.opEquals(rhs)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jun 16 19:54:21 UTC 2019
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: nobody at puremagic.com
Reporter: n8sh.secondary at hotmail.com
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);
}
}
---
--
More information about the Digitalmars-d-bugs
mailing list