From 973038da6a080263a6347ee75362541e004bdcfe Mon Sep 17 00:00:00 2001 From: jdalton Date: Fri, 27 Feb 2015 20:52:10 -0800 Subject: [PATCH] Optimize `baseIndexOf`, `indexOfNaN`, and `baseFlatten`. --- lodash.src.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index a32c147ca..1630d1b66 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -320,7 +320,7 @@ if (value !== value) { return indexOfNaN(array, fromIndex); } - var index = (fromIndex || 0) - 1, + var index = fromIndex == null ? -1 : (fromIndex - 1), length = array.length; while (++index < length) { @@ -514,7 +514,7 @@ */ function indexOfNaN(array, fromIndex, fromRight) { var length = array.length, - index = fromRight ? (fromIndex || length) : ((fromIndex || 0) - 1); + index = fromIndex == null ? (fromRight ? length : -1) : (fromIndex + (fromRight ? 0 : -1)); while ((fromRight ? index-- : ++index < length)) { var other = array[index]; @@ -2143,7 +2143,7 @@ * @returns {Array} Returns the new flattened array. */ function baseFlatten(array, isDeep, isStrict, fromIndex) { - var index = (fromIndex || 0) - 1, + var index = fromIndex == null ? -1 : (fromIndex - 1), length = array.length, resIndex = -1, result = [];