Optimize _.max and _.min.

Former-commit-id: 8c5dc8606d00e68dee63f06438e83c3bd65f3b29
This commit is contained in:
John-David Dalton
2012-11-06 01:46:36 -08:00
parent 537643a4c3
commit 3138523b5b
2 changed files with 6 additions and 6 deletions

View File

@@ -118,10 +118,10 @@
'lastIndexOf': [], 'lastIndexOf': [],
'lateBind': ['isFunction'], 'lateBind': ['isFunction'],
'map': ['forEach', 'isArray'], 'map': ['forEach', 'isArray'],
'max': ['forEach'], 'max': ['forEach', 'isArray'],
'memoize': [], 'memoize': [],
'merge': ['forOwn', 'isArray', 'isPlainObject'], 'merge': ['forOwn', 'isArray', 'isPlainObject'],
'min': ['forEach'], 'min': ['forEach', 'isArray'],
'mixin': ['forEach', 'functions'], 'mixin': ['forEach', 'functions'],
'noConflict': [], 'noConflict': [],
'object': [], 'object': [],

View File

@@ -2105,7 +2105,7 @@
* @static * @static
* @memberOf _ * @memberOf _
* @category Collections * @category Collections
* @param {Array|Object} collection The collection to iterate over. * @param {Array|Object|String} collection The collection to iterate over.
* @param {Function} [callback] The function called per iteration. * @param {Function} [callback] The function called per iteration.
* @param {Mixed} [thisArg] The `this` binding of `callback`. * @param {Mixed} [thisArg] The `this` binding of `callback`.
* @returns {Mixed} Returns the maximum value. * @returns {Mixed} Returns the maximum value.
@@ -2126,7 +2126,7 @@
length = collection ? collection.length : 0, length = collection ? collection.length : 0,
result = computed; result = computed;
if (callback || typeof length != 'number') { if (callback || !isArray(collection)) {
callback = createCallback(callback, thisArg); callback = createCallback(callback, thisArg);
forEach(collection, function(value, index, collection) { forEach(collection, function(value, index, collection) {
var current = callback(value, index, collection); var current = callback(value, index, collection);
@@ -2154,7 +2154,7 @@
* @static * @static
* @memberOf _ * @memberOf _
* @category Collections * @category Collections
* @param {Array|Object} collection The collection to iterate over. * @param {Array|Object|String} collection The collection to iterate over.
* @param {Function} [callback] The function called per iteration. * @param {Function} [callback] The function called per iteration.
* @param {Mixed} [thisArg] The `this` binding of `callback`. * @param {Mixed} [thisArg] The `this` binding of `callback`.
* @returns {Mixed} Returns the minimum value. * @returns {Mixed} Returns the minimum value.
@@ -2169,7 +2169,7 @@
length = collection ? collection.length : 0, length = collection ? collection.length : 0,
result = computed; result = computed;
if (callback || typeof length != 'number') { if (callback || !isArray(collection)) {
callback = createCallback(callback, thisArg); callback = createCallback(callback, thisArg);
forEach(collection, function(value, index, collection) { forEach(collection, function(value, index, collection) {
var current = callback(value, index, collection); var current = callback(value, index, collection);