Simplify equalObjects.

This commit is contained in:
John-David Dalton
2014-12-14 18:58:09 -08:00
parent 7464d82243
commit 470d35e96c

View File

@@ -3251,8 +3251,7 @@
if (objLength != othLength && !isWhere) { if (objLength != othLength && !isWhere) {
return false; return false;
} }
var objHasCtor, var hasCtor,
othHasCtor,
index = -1; index = -1;
while (++index < objLength) { while (++index < objLength) {
@@ -3271,20 +3270,17 @@
if (!result) { if (!result) {
return result; return result;
} }
objHasCtor || (objHasCtor = key == 'constructor'); hasCtor || (hasCtor = key == 'constructor');
othHasCtor || (othHasCtor = key == 'constructor');
} }
if (objHasCtor != othHasCtor) { if (!hasCtor) {
return false; var objCtor = object.constructor,
} othCtor = other.constructor;
// In older versions of Opera, `arguments` objects have `Array` constructors.
var objCtor = object.constructor,
othCtor = other.constructor;
// Non `Object` object instances with different constructors are not equal. // Non `Object` object instances with different constructors are not equal.
if (!objHasCtor && objCtor != othCtor && ('constructor' in object && 'constructor' in other) && if (objCtor != othCtor && ('constructor' in object && 'constructor' in other) &&
!(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) { !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) {
return false; return false;
}
} }
return true; return true;
} }