On 04/03/2014 09:03 AM, dnspies wrote:
If two dynamic arrays point to the same place in memory, is it fast to compare them for equality? or does every element still have to be compared?
Equals will first check for memory location. This is from the runtime: bool opEquals(Object lhs, Object rhs) { // If aliased to the same object or both null => equal if (lhs is rhs) return true; // If either is null => non-equal if (lhs is null || rhs is null) return false; // If same exact type => one call to method opEquals if (typeid(lhs) is typeid(rhs) || typeid(lhs).opEquals(typeid(rhs))) return lhs.opEquals(rhs); // General case => symmetric calls to method opEquals return lhs.opEquals(rhs) && rhs.opEquals(lhs); }