Skip to content

Commit

Permalink
A few more length variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
braddunbar committed Jul 24, 2013
1 parent b450f13 commit a187077
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
if (nativeForEach && obj.forEach === nativeForEach) {
obj.forEach(iterator, context);
} else if (obj.length === +obj.length) {
for (var i = 0, l = obj.length; i < l; i++) {
for (var i = 0, length = obj.length; i < length; i++) {
if (iterator.call(context, obj[i], i, obj) === breaker) return;
}
} else {
Expand Down Expand Up @@ -508,7 +508,7 @@
_.object = function(list, values) {
if (list == null) return {};
var result = {};
for (var i = 0, l = list.length; i < l; i++) {
for (var i = 0, length = list.length; i < length; i++) {
if (values) {
result[list[i]] = values[i];
} else {
Expand All @@ -526,17 +526,17 @@
// for **isSorted** to use binary search.
_.indexOf = function(array, item, isSorted) {
if (array == null) return -1;
var i = 0, l = array.length;
var i = 0, length = array.length;
if (isSorted) {
if (typeof isSorted == 'number') {
i = (isSorted < 0 ? Math.max(0, l + isSorted) : isSorted);
i = (isSorted < 0 ? Math.max(0, length + isSorted) : isSorted);
} else {
i = _.sortedIndex(array, item);
return array[i] === item ? i : -1;
}
}
if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted);
for (; i < l; i++) if (array[i] === item) return i;
for (; i < length; i++) if (array[i] === item) return i;
return -1;
};

Expand All @@ -562,11 +562,11 @@
}
step = arguments[2] || 1;

var len = Math.max(Math.ceil((stop - start) / step), 0);
var length = Math.max(Math.ceil((stop - start) / step), 0);
var idx = 0;
var range = new Array(len);
var range = new Array(length);

while(idx < len) {
while(idx < length) {
range[idx++] = start;
start += step;
}
Expand Down

0 comments on commit a187077

Please sign in to comment.