mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 01:47:48 +00:00
Optimize object comparisons in _.isEqual.
This commit is contained in:
@@ -4007,29 +4007,22 @@
|
|||||||
if (objLength != othLength && !isLoose) {
|
if (objLength != othLength && !isLoose) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var skipCtor = isLoose,
|
var index = objLength;
|
||||||
index = -1;
|
while (index--) {
|
||||||
|
var key = objProps[index];
|
||||||
while (++index < objLength) {
|
if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) {
|
||||||
var key = objProps[index],
|
return false;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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;
|
return false;
|
||||||
}
|
}
|
||||||
skipCtor || (skipCtor = key == 'constructor');
|
skipCtor || (skipCtor = key == 'constructor');
|
||||||
|
|||||||
Reference in New Issue
Block a user