Optimize _.template when no evaluate delimiters are used and optimize _.bind when partially applied in V8.

Former-commit-id: 25489d41ba3cac7ac3f1414e09f1971a11a779be
This commit is contained in:
John-David Dalton
2012-07-02 00:07:22 -04:00
parent 6af4652161
commit 3b4074bfc7
3 changed files with 113 additions and 73 deletions

View File

@@ -207,7 +207,10 @@
source = source.replace(RegExp('\\.(' + propWhitelist.join('|') + ')\\b', 'g'), "['$1']");
// remove brackets from `_.escape()` in `tokenizeEscape`
source = source.replace("_['escape'](\"", '_.escape("');
source = source.replace(/_\['escape']\("/, '_.escape("');
// remove brackets from `_.escape()` in `_.template`
source = source.replace(/__e *= *_\['escape']/, '__e=_.escape');
// remove brackets from `result[length].value` in `_.sortBy`
source = source.replace("result[length]['value']", 'result[length].value');
@@ -220,6 +223,11 @@
});
});
// remove whitespace from `_.template` related regexpes
source = source.replace(/(?:reEmptyString\w+|reInsertVariable) *=.+/g, function(match) {
return match.replace(/ /g, '');
});
// remove newline from double-quoted string in `_.template`
source = source.replace('"\';\\n"', '"\';"');