mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Optimize baseIndexOf, indexOfNaN, and baseFlatten.
This commit is contained in:
@@ -320,7 +320,7 @@
|
|||||||
if (value !== value) {
|
if (value !== value) {
|
||||||
return indexOfNaN(array, fromIndex);
|
return indexOfNaN(array, fromIndex);
|
||||||
}
|
}
|
||||||
var index = (fromIndex || 0) - 1,
|
var index = fromIndex == null ? -1 : (fromIndex - 1),
|
||||||
length = array.length;
|
length = array.length;
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
@@ -514,7 +514,7 @@
|
|||||||
*/
|
*/
|
||||||
function indexOfNaN(array, fromIndex, fromRight) {
|
function indexOfNaN(array, fromIndex, fromRight) {
|
||||||
var length = array.length,
|
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)) {
|
while ((fromRight ? index-- : ++index < length)) {
|
||||||
var other = array[index];
|
var other = array[index];
|
||||||
@@ -2143,7 +2143,7 @@
|
|||||||
* @returns {Array} Returns the new flattened array.
|
* @returns {Array} Returns the new flattened array.
|
||||||
*/
|
*/
|
||||||
function baseFlatten(array, isDeep, isStrict, fromIndex) {
|
function baseFlatten(array, isDeep, isStrict, fromIndex) {
|
||||||
var index = (fromIndex || 0) - 1,
|
var index = fromIndex == null ? -1 : (fromIndex - 1),
|
||||||
length = array.length,
|
length = array.length,
|
||||||
resIndex = -1,
|
resIndex = -1,
|
||||||
result = [];
|
result = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user