Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use a separate variable for the iterator result value.

  • Loading branch information...
commit e3fa7a6da53895c5bdb816615e658f23f0ba1112 1 parent 2524e51
@braddunbar braddunbar authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 underscore.js
View
4 underscore.js
@@ -289,11 +289,11 @@
// an object should be inserted so as to maintain order. Uses binary search.
_.sortedIndex = function(array, obj, iterator) {
iterator || (iterator = _.identity);
- obj = iterator(obj);
+ var value = iterator(obj);
var low = 0, high = array.length;
while (low < high) {
var mid = (low + high) >> 1;
- iterator(array[mid]) < obj ? low = mid + 1 : high = mid;
+ iterator(array[mid]) < value ? low = mid + 1 : high = mid;
}
return low;
};
Please sign in to comment.
Something went wrong with that request. Please try again.