mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
Optimize object comparisons in _.isEqual.
This commit is contained in:
@@ -4007,29 +4007,22 @@
|
||||
if (objLength != othLength && !isLoose) {
|
||||
return false;
|
||||
}
|
||||
var skipCtor = isLoose,
|
||||
index = -1;
|
||||
|
||||
while (++index < objLength) {
|
||||
var key = objProps[index],
|
||||
result = isLoose ? key in other : hasOwnProperty.call(other, key);
|
||||
|
||||
if (result) {
|
||||
var objValue = object[key],
|
||||
othValue = other[key];
|
||||
|
||||
result = undefined;
|
||||
if (customizer) {
|
||||
result = isLoose
|
||||
? customizer(othValue, objValue, key)
|
||||
: customizer(objValue, othValue, key);
|
||||
}
|
||||
if (result === undefined) {
|
||||
// Recursively compare objects (susceptible to call stack limits).
|
||||
result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB);
|
||||
}
|
||||
var index = objLength;
|
||||
while (index--) {
|
||||
var key = objProps[index];
|
||||
if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) {
|
||||
return false;
|
||||
}
|
||||
if (!result) {
|
||||
}
|
||||
var skipCtor = isLoose;
|
||||
while (++index < objLength) {
|
||||
key = objProps[index];
|
||||
var objValue = object[key],
|
||||
othValue = other[key],
|
||||
result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined;
|
||||
|
||||
// Recursively compare objects (susceptible to call stack limits).
|
||||
if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) {
|
||||
return false;
|
||||
}
|
||||
skipCtor || (skipCtor = key == 'constructor');
|
||||
|
||||
Reference in New Issue
Block a user