Skip to content

Commit

Permalink
perf: correct way to avoid calling concat() re: #11380
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Nov 24, 2023
1 parent e3cccc3 commit 62d5302
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/types/array/methods/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,13 @@ const methods = {
if (val != null && utils.hasUserDefinedProperty(val, '$each')) {
atomics.$push = val;
} else {
atomics.$push.$each.push(val);
if (val.length < 10000) {
atomics.$push.$each.push(...val);
} else {
for (const v of val) {
atomics.$push.$each.push(v);
}
}
}
} else {
atomics[op] = val;
Expand Down Expand Up @@ -711,7 +717,7 @@ const methods = {
'with different `$position`');
}
atomic = values;
ret = [].push.apply(arr, values);
ret = _basePush.apply(arr, values);
}

this._registerAtomic('$push', atomic);
Expand Down

0 comments on commit 62d5302

Please sign in to comment.