|
47 | 47 | /** Used to generate unique IDs */
|
48 | 48 | var idCounter = 0;
|
49 | 49 |
|
| 50 | + /** Used by `cachedContains` as the default size when optimizations are enabled for large arrays */ |
| 51 | + var largeArraySize = 30; |
| 52 | + |
50 | 53 | /** Used to restore the original `_` reference in `noConflict` */
|
51 | 54 | var oldDash = window._;
|
52 | 55 |
|
|
548 | 551 | fromIndex || (fromIndex = 0);
|
549 | 552 |
|
550 | 553 | var length = array.length,
|
551 |
| - isLarge = (length - fromIndex) >= (largeSize || 30), |
| 554 | + isLarge = (length - fromIndex) >= (largeSize || largeArraySize), |
552 | 555 | cache = isLarge ? {} : array;
|
553 | 556 |
|
554 | 557 | if (isLarge) {
|
|
2365 | 2368 | var where = createIterator(filterIteratorOptions, {
|
2366 | 2369 | 'args': 'collection, properties',
|
2367 | 2370 | 'top':
|
2368 |
| - 'var pass, prop, propIndex, props = [];\n' + |
| 2371 | + 'var props = [];\n' + |
2369 | 2372 | 'forIn(properties, function(value, prop) { props.push(prop) });\n' +
|
2370 | 2373 | 'var propsLength = props.length',
|
2371 | 2374 | 'inLoop':
|
2372 |
| - 'for (pass = true, propIndex = 0; propIndex < propsLength; propIndex++) {\n' + |
| 2375 | + 'for (var prop, pass = true, propIndex = 0; propIndex < propsLength; propIndex++) {\n' + |
2373 | 2376 | ' prop = props[propIndex];\n' +
|
2374 | 2377 | ' if (!(pass = value[prop] === properties[prop])) break\n' +
|
2375 | 2378 | '}\n' +
|
2376 |
| - 'if (pass) result.push(value)' |
| 2379 | + 'pass && result.push(value)' |
2377 | 2380 | });
|
2378 | 2381 |
|
2379 | 2382 | /*--------------------------------------------------------------------------*/
|
|
2597 | 2600 | return result;
|
2598 | 2601 | }
|
2599 | 2602 | var value,
|
| 2603 | + argsLength = arguments.length, |
| 2604 | + cache = [], |
2600 | 2605 | index = -1,
|
2601 |
| - length = array.length, |
2602 |
| - others = slice.call(arguments, 1), |
2603 |
| - cache = []; |
| 2606 | + length = array.length; |
2604 | 2607 |
|
2605 |
| - while (++index < length) { |
| 2608 | + array: while (++index < length) { |
2606 | 2609 | value = array[index];
|
2607 |
| - if (indexOf(result, value) < 0 && |
2608 |
| - every(others, function(other, index) { |
2609 |
| - return (cache[index] || (cache[index] = cachedContains(other)))(value); |
2610 |
| - })) { |
| 2610 | + if (indexOf(result, value) < 0) { |
| 2611 | + for (var argsIndex = 1; argsIndex < argsLength; argsIndex++) { |
| 2612 | + if (!(cache[argsIndex] || (cache[argsIndex] = cachedContains(arguments[argsIndex])))(value)) { |
| 2613 | + continue array; |
| 2614 | + } |
| 2615 | + } |
2611 | 2616 | result.push(value);
|
2612 | 2617 | }
|
2613 | 2618 | }
|
|
0 commit comments