diff --git a/doc/contributing/primordials.md b/doc/contributing/primordials.md index 4ca383c41cbd25..7de217c129d2c7 100644 --- a/doc/contributing/primordials.md +++ b/doc/contributing/primordials.md @@ -106,6 +106,7 @@ performance of code in Node.js. * Methods that mutate the internal state of arrays: * `ArrayPrototypePush` + * `ArrayPrototypePushApply`: also fails with a RangeError on large arrays * `ArrayPrototypePop` * `ArrayPrototypeShift` * `ArrayPrototypeUnshift` diff --git a/lib/internal/perf/observe.js b/lib/internal/perf/observe.js index 048eb47cebaae7..9250f655c6ff86 100644 --- a/lib/internal/perf/observe.js +++ b/lib/internal/perf/observe.js @@ -6,7 +6,6 @@ const { ArrayPrototypeFilter, ArrayPrototypeIncludes, ArrayPrototypePush, - ArrayPrototypePushApply, ArrayPrototypeSlice, ArrayPrototypeSort, Error, @@ -307,7 +306,9 @@ class PerformanceObserver { maybeIncrementObserverCount(type); if (buffered) { const entries = filterBufferMapByNameAndType(undefined, type); - ArrayPrototypePushApply(this.#buffer, entries); + for (let i = 0; i < entries.length; i++) { + ArrayPrototypePush(this.#buffer, entries[i]); + } kPending.add(this); if (kPending.size) queuePending(); @@ -514,9 +515,15 @@ function filterBufferMapByNameAndType(name, type) { return []; } else { bufferList = []; - ArrayPrototypePushApply(bufferList, markEntryBuffer); - ArrayPrototypePushApply(bufferList, measureEntryBuffer); - ArrayPrototypePushApply(bufferList, resourceTimingBuffer); + for (let i = 0; i < markEntryBuffer.length; i++) { + ArrayPrototypePush(bufferList, markEntryBuffer[i]); + } + for (let i = 0; i < measureEntryBuffer.length; i++) { + ArrayPrototypePush(bufferList, measureEntryBuffer[i]); + } + for (let i = 0; i < resourceTimingBuffer.length; i++) { + ArrayPrototypePush(bufferList, resourceTimingBuffer[i]); + } } if (name !== undefined) { bufferList = ArrayPrototypeFilter(bufferList, (buffer) => buffer.name === name);