Permalink
Browse files

Use a separate variable for the iterator result value.

  • Loading branch information...
1 parent 2524e51 commit e3fa7a6da53895c5bdb816615e658f23f0ba1112 @braddunbar braddunbar committed Apr 26, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 underscore.js
View
@@ -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;
};

0 comments on commit e3fa7a6

Please sign in to comment.