mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Revert "merging in faster indexOf patch ... arguably faster than the native implementation, but oh well. #245"
This reverts commit f099038a9d.
This commit is contained in:
@@ -381,13 +381,14 @@
|
|||||||
// for **isSorted** to use binary search.
|
// for **isSorted** to use binary search.
|
||||||
_.indexOf = function(array, item, isSorted) {
|
_.indexOf = function(array, item, isSorted) {
|
||||||
if (array == null) return -1;
|
if (array == null) return -1;
|
||||||
var obj, i = 0;
|
var i, l;
|
||||||
if (isSorted) {
|
if (isSorted) {
|
||||||
i = _.sortedIndex(array, item);
|
i = _.sortedIndex(array, item);
|
||||||
return array[i] === item ? i : -1;
|
return array[i] === item ? i : -1;
|
||||||
}
|
}
|
||||||
if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item);
|
if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item);
|
||||||
while (obj = array[i++]) if (obj === item) return i - 1;
|
var o,i=0;
|
||||||
|
while( o = array[i++] ) if (o === item) return i-1;
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user