Optimize _.forEach, _.forIn, and _.forOwn.

Former-commit-id: 5d3b83ec0d5240ee14a86421994de86f311089fd
This commit is contained in:
John-David Dalton
2012-11-24 23:02:44 -06:00
parent d2d1d42d0f
commit 221e0e550c
6 changed files with 50 additions and 48 deletions

View File

@@ -470,7 +470,7 @@
*/
var forEachIteratorOptions = {
'args': 'collection, callback, thisArg',
'top': 'callback = createCallback(callback, thisArg)',
'top': 'callback = callback && thisArg === undefined ? callback : createCallback(callback, thisArg)',
'arrayLoop': 'if (callback(iteratee[index], index, collection) === false) return result',
'objectLoop': 'if (callback(iteratee[index], index, collection) === false) return result'
};
@@ -682,7 +682,7 @@
// create the function factory
var factory = createFunction(
'createCallback, hasOwnProperty, isArguments, isString, objectTypes, ' +
'nativeKeys, propertyIsEnumerable',
'nativeKeys, propertyIsEnumerable, undefined',
'return function(' + args + ') {\n' + iteratorTemplate(data) + '\n}'
);
// return the compiled function
@@ -1457,7 +1457,7 @@
/**
* Checks if `value` is `NaN`.
*
* Note: This is not the same as native `isNaN`, which will return true for
* Note: This is not the same as native `isNaN`, which will return `true` for
* `undefined` and other values. See http://es5.github.com/#x15.1.2.4.
*
* @static