Reduce size of "mobile" and "underscore" builds.

Former-commit-id: 062dc03e3d3dd7a8e1ceb6a8b4ea155394a9b899
This commit is contained in:
John-David Dalton
2012-09-03 23:20:18 -07:00
parent 0c92d3cbb2
commit c60f3da32e
2 changed files with 47 additions and 40 deletions

View File

@@ -88,18 +88,21 @@
' : value;',
' }'
].join('\n'));
}
if (isMobile) {
source = replaceVar(source, 'isKeysFast', 'false');
// remove Opera 10.53-10.60 JIT fixes
source = source.replace(/length *> *-1 *&& *length/g, 'length');
// remove `prototype` [[Enumerable]] fix from `_.keys`
source = source.replace(/(?:\s*\/\/.*)*\n( +)if *\(.+?propertyIsEnumerable[\s\S]+?\n\1}/, '');
// remove `prototype` [[Enumerable]] fix from `iteratorTemplate`
source = source
.replace(/(?: *\/\/.*\n)*\s*' *(?:<% *)?if *\(!hasDontEnumBug *(?:&&|\))[\s\S]+?<% *} *(?:%>|').+/g, '')
.replace(/!hasDontEnumBug *\|\|/g, '');
}
if (isMobile) {
source = replaceVar(source, 'isKeysFast', 'false');
}
vm.runInNewContext(source, sandbox);
return sandbox._;
}());
@@ -946,11 +949,15 @@
// build replacement code
lodash.forOwn({
'Arguments': 'argsClass',
'Date': 'dateClass',
'Number': 'numberClass',
'RegExp': 'regexpClass',
'String': 'stringClass'
}, function(value, key) {
if (!isUnderscore && key == 'Arguments') {
return;
}
var funcName = 'is' + key,
funcCode = matchFunction(source, funcName);