Navigation Menu

Skip to content

Commit

Permalink
Use and if statement, drop unnecessary guard.
Browse files Browse the repository at this point in the history
  • Loading branch information
braddunbar committed Feb 7, 2014
1 parent ff32da2 commit b299759
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions underscore.js
Expand Up @@ -260,11 +260,13 @@
if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
return Math.max.apply(Math, obj);
}
if (!iterator && _.isEmpty(obj)) return -Infinity;
var result = -Infinity, lastComputed = -Infinity;
each(obj, function(value, index, list) {
var computed = iterator ? iterator.call(context, value, index, list) : value;
computed > lastComputed && (result = value, lastComputed = computed);
if (computed > lastComputed) {
result = value;
lastComputed = computed;
}
});
return result;
};
Expand All @@ -274,11 +276,13 @@
if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
return Math.min.apply(Math, obj);
}
if (!iterator && _.isEmpty(obj)) return Infinity;
var result = Infinity, lastComputed = Infinity;
each(obj, function(value, index, list) {
var computed = iterator ? iterator.call(context, value, index, list) : value;
computed < lastComputed && (result = value, lastComputed = computed);
if (computed < lastComputed) {
result = value;
lastComputed = computed;
}
});
return result;
};
Expand Down

0 comments on commit b299759

Please sign in to comment.