From f40f66d29bf52d31517e7887c13549bd20ba2792 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 22 Feb 2016 23:34:25 -0800 Subject: [PATCH] Remove a `isTypedArray` check and unnecessary stack creation from `baseIsEqualDeep`. --- lodash.js | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/lodash.js b/lodash.js index bb1476f37..489c22f83 100644 --- a/lodash.js +++ b/lodash.js @@ -2877,41 +2877,36 @@ if (!objIsArr) { objTag = getTag(object); - if (objTag == argsTag) { - objTag = objectTag; - } else if (objTag != objectTag) { - objIsArr = isTypedArray(object); - } + objTag = objTag == argsTag ? objectTag : objTag; } if (!othIsArr) { othTag = getTag(other); - if (othTag == argsTag) { - othTag = objectTag; - } else if (othTag != objectTag) { - othIsArr = isTypedArray(other); - } + othTag = othTag == argsTag ? objectTag : othTag; } var objIsObj = objTag == objectTag && !isHostObject(object), othIsObj = othTag == objectTag && !isHostObject(other), isSameTag = objTag == othTag; - stack || (stack = new Stack); - if (isSameTag && !(objIsArr || objIsObj)) { - return equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack); + if (isSameTag && !objIsObj) { + stack || (stack = new Stack); + return (objIsArr || isTypedArray(object)) + ? equalArrays(object, other, equalFunc, customizer, bitmask, stack) + : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack); } - var isPartial = bitmask & PARTIAL_COMPARE_FLAG; - if (!isPartial) { + if (!(bitmask & PARTIAL_COMPARE_FLAG)) { var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); if (objIsWrapped || othIsWrapped) { + stack || (stack = new Stack); return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack); } } if (!isSameTag) { return false; } - return (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, bitmask, stack); + stack || (stack = new Stack); + return equalObjects(object, other, equalFunc, customizer, bitmask, stack); } /**