Use nativeSlice when possible and adjust largeArraySize to account for the recent cachedContains tweaks.

Former-commit-id: 9fe4dc10c74fb7a4b8e5cff434a4146d274f15d4
This commit is contained in:
John-David Dalton
2013-04-06 01:26:21 -07:00
parent 4a03ba3874
commit e97e645eda
10 changed files with 338 additions and 390 deletions

View File

@@ -175,7 +175,7 @@
'value': ['forOwn', 'isArray'],
'values': ['keys'],
'where': ['filter'],
'without': ['indexOf'],
'without': ['difference'],
'wrap': [],
'zip': ['max', 'pluck'],
'zipObject': [],
@@ -2392,23 +2392,6 @@
'}'
].join('\n'));
// replace `_.without`
source = replaceFunction(source, 'without', [
'function without(array) {',
' var index = -1,',
' length = array.length,',
' result = [];',
'',
' while (++index < length) {',
' var value = array[index];',
' if (indexOf(arguments, value, 1) < 0) {',
' result.push(value);',
' }',
' }',
' return result',
'}'
].join('\n'));
// add `_.findWhere`
source = source.replace(matchFunction(source, 'find'), function(match) {
var indent = getIndent(match);
@@ -2446,10 +2429,9 @@
});
});
// replace `slice` with `slice.call`
// replace `slice` with `nativeSlice.call`
source = removeFunction(source, 'slice');
source = source.replace(/^(( *)setTimeout = context.setTimeout)([,;])/m, '$1,\n$2slice = arrayRef.slice$3');
source = source.replace(/([^.]\bslice)\(/g, '$1.call(');
source = source.replace(/([^.])\bslice\(/g, '$1nativeSlice.call(');
// replace `lodash.createCallback` references with `createCallback`
if (!exposeCreateCallback) {