Remove the large array optimization for _.uniq from the underscore build.

Former-commit-id: 4cafbf2568c786834e40f0e4ea9b64ff670f60b7
This commit is contained in:
John-David Dalton
2012-11-02 22:31:04 -07:00
parent b17c576705
commit 9dc33c6086
2 changed files with 48 additions and 24 deletions

View File

@@ -1151,6 +1151,36 @@
' }'
].join('\n'));
// replace `_.uniq`
source = source.replace(/^( +)function uniq[\s\S]+?\n\1}/m, [
' function uniq(array, isSorted, callback, thisArg) {',
' var index = -1,',
' length = array ? array.length : 0,',
' result = [],',
' seen = result;',
'',
' if (callback) {',
' seen = [];',
' callback = createCallback(callback, thisArg);',
' }',
' while (++index < length) {',
' var value = array[index],',
' computed = callback ? callback(value, index, array) : value;',
'',
' if (isSorted',
' ? !index || seen[seen.length - 1] !== computed',
' : indexOf(seen, computed) < 0',
' ) {',
' if (callback) {',
' seen.push(computed);',
' }',
' result.push(value);',
' }',
' }',
' return result;',
' }'
].join('\n'));
// replace `_.without`
source = source.replace(/^( +)function without[\s\S]+?\n\1}/m, [
' function without(array) {',
@@ -1177,11 +1207,6 @@
// simplify DOM node check from `_.isEqual`
source = source.replace(/(if *\(className *!= *objectClass).+?noNodeClass[\s\S]+?{/, '$1) {');
// remove arguments juggling from `_.uniq`
source = source.replace(matchFunction(source, 'uniq'), function(match) {
return match.replace(/(?: *\/\/.*\n)*( +)if *\(typeof isSorted[^}]+?}\n/, '');
});
// remove unused features from `createBound`
if (buildMethods.indexOf('partial') == -1) {
source = source.replace(matchFunction(source, 'createBound'), function(match) {