Remove the binding optimization from all but the modern build.

Former-commit-id: 1023ccc976e180425dabaa1b61e873e542aa3c2a
This commit is contained in:
John-David Dalton
2013-05-21 08:42:13 -07:00
parent 9ffcd382b4
commit f8e67b8e68
3 changed files with 54 additions and 35 deletions

View File

@@ -1095,6 +1095,26 @@
return source.replace(getCreateObjectFallback(source), '');
}
/**
* Removes the binding optimization from `source`.
*
* @private
* @param {String} source The source to process.
* @returns {String} Returns the modified source.
*/
function removeBindingOptimization(source) {
source = removeVar(source, 'fnToString');
source = removeVar(source, 'reThis');
// remove `reThis` from `createCallback`
source = source.replace(matchFunction(source, 'createCallback'), function(match) {
return match.replace(/\s*\|\|\s*\(reThis[\s\S]+?\)\)\)/, '');
});
return source;
}
/**
* Removes the `Object.keys` object iteration optimization from `source`.
*
@@ -1270,7 +1290,7 @@
// remove `support.nonEnumArgs` from `_.keys`
source = source.replace(matchFunction(source, 'keys'), function(match) {
return match
.replace(/(?:\s*\|\|\s*)?\(support\.nonEnumArgs[^)]+\)\)/, '')
.replace(/(?:\s*\|\|\s*)?\(support\.nonEnumArgs[\s\S]+?\)\)/, '')
.replace(/\s*if *\(\s*\)[^}]+}/, '');
});
@@ -2044,6 +2064,9 @@
].join('\n'));
}
}
if (isLegacy || isMobile || isUnderscore) {
source = removeBindingOptimization(source);
}
if (isMobile || isUnderscore) {
source = removeKeysOptimization(source);
source = removeSetImmediate(source);