Skip to content

Commit

Permalink
Revert "merging in faster indexOf patch ... arguably faster than the …
Browse files Browse the repository at this point in the history
…native implementation, but oh well. jashkenas#245"

This reverts commit f099038.
  • Loading branch information
jashkenas committed Jul 13, 2011
1 parent f099038 commit a6cba68
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,14 @@
// for **isSorted** to use binary search.
_.indexOf = function(array, item, isSorted) {
if (array == null) return -1;
var obj, i = 0;
var i, l;
if (isSorted) {
i = _.sortedIndex(array, item);
return array[i] === item ? i : -1;
}
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;
};

Expand Down

0 comments on commit a6cba68

Please sign in to comment.