Skip to content

Commit 62d5302

Browse files
committed
perf: correct way to avoid calling concat() re: #11380
1 parent e3cccc3 commit 62d5302

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/types/array/methods/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,13 @@ const methods = {
374374
if (val != null && utils.hasUserDefinedProperty(val, '$each')) {
375375
atomics.$push = val;
376376
} else {
377-
atomics.$push.$each.push(val);
377+
if (val.length < 10000) {
378+
atomics.$push.$each.push(...val);
379+
} else {
380+
for (const v of val) {
381+
atomics.$push.$each.push(v);
382+
}
383+
}
378384
}
379385
} else {
380386
atomics[op] = val;
@@ -711,7 +717,7 @@ const methods = {
711717
'with different `$position`');
712718
}
713719
atomic = values;
714-
ret = [].push.apply(arr, values);
720+
ret = _basePush.apply(arr, values);
715721
}
716722

717723
this._registerAtomic('$push', atomic);

0 commit comments

Comments
 (0)