From 54482e9cc4ae722c91f7e1fa47593f5c4d32f076 Mon Sep 17 00:00:00 2001 From: Roberto Bianchi Date: Fri, 13 Nov 2026 14:47:46 +0100 Subject: [PATCH] lib: use indexed appends instead of ArrayPrototypePush ArrayPrototypePush is listed among primordials with known performance issues. Replace plain single-value statement calls on local or private arrays with indexed appends. Calls whose return value is used, that push multiple or spread values, that target publicly reachable arrays, or whose value expression may run user code are left unchanged. Signed-off-by: Roberto Bianchi --- lib/async_hooks.js | 3 +-- lib/child_process.js | 14 +++++----- lib/dgram.js | 2 +- lib/dns.js | 3 +-- lib/domain.js | 4 +-- lib/https.js | 3 +-- lib/internal/bench_runner/benchmark.js | 11 ++++---- .../bench_runner/benchmarks_stream.js | 2 +- lib/internal/bench_runner/cli.js | 22 ++++++++-------- lib/internal/bench_runner/environment.js | 3 +-- lib/internal/bench_runner/harness.js | 16 ++++++------ lib/internal/bench_runner/reporter/spec.js | 14 +++++----- lib/internal/blob.js | 5 ++-- lib/internal/crypto/util.js | 3 +-- lib/internal/crypto/webidl.js | 4 +-- lib/internal/crypto/x509_generation.js | 6 ++--- lib/internal/debugger/inspect_repl.js | 9 +++---- lib/internal/errors.js | 8 +++--- lib/internal/fs/dir.js | 4 +-- lib/internal/fs/watchers.js | 6 ++--- lib/internal/main/watch_mode.js | 7 +++-- lib/internal/modules/cjs/loader.js | 4 +-- lib/internal/modules/customization_hooks.js | 7 +++-- lib/internal/modules/esm/translators.js | 7 +++-- lib/internal/modules/helpers.js | 3 +-- lib/internal/perf/observe.js | 8 +++--- lib/internal/process/permission.js | 3 +-- lib/internal/promise_hooks.js | 6 ++--- lib/internal/readline/promises.js | 9 +++---- lib/internal/repl/completion.js | 26 +++++++++---------- lib/internal/streams/fast-utf8-stream.js | 12 ++++----- lib/internal/streams/iter/classic.js | 6 ++--- lib/internal/streams/iter/consumers.js | 2 +- lib/internal/streams/operators.js | 3 +-- lib/internal/test_runner/coverage.js | 4 +-- lib/internal/test_runner/mock/mock.js | 6 ++--- lib/internal/test_runner/reporter/junit.js | 4 +-- lib/internal/test_runner/reporter/rerun.js | 7 +++-- lib/internal/test_runner/reporter/tap.js | 3 +-- lib/internal/test_runner/runner.js | 22 ++++++++-------- lib/internal/test_runner/tag_filter.js | 20 +++++++------- lib/internal/test_runner/tests_stream.js | 3 +-- lib/internal/test_runner/utils.js | 4 +-- lib/internal/util/parse_args/parse_args.js | 8 +++--- lib/internal/vfs/providers/memory.js | 2 +- lib/internal/vfs/providers/sea.js | 2 +- lib/internal/vfs/providers/ziparchive.js | 2 +- lib/internal/vfs/root.js | 6 ++--- lib/internal/vfs/watcher.js | 2 +- lib/internal/webidl.js | 3 +-- lib/internal/webstreams/readablestream.js | 2 +- lib/internal/webworker.js | 3 +-- lib/internal/zip/buffer.js | 5 ++-- lib/internal/zip/extra-fields.js | 3 +-- lib/internal/zip/file.js | 10 +++---- lib/internal/zip/headers.js | 3 +-- lib/net.js | 6 ++--- lib/os.js | 2 +- lib/repl.js | 4 +-- lib/tls.js | 8 +++--- lib/util.js | 3 +-- lib/wasi.js | 2 +- 62 files changed, 184 insertions(+), 210 deletions(-) diff --git a/lib/async_hooks.js b/lib/async_hooks.js index b0106020d64c..f05251971bf5 100644 --- a/lib/async_hooks.js +++ b/lib/async_hooks.js @@ -3,7 +3,6 @@ const { ArrayPrototypeIncludes, ArrayPrototypeIndexOf, - ArrayPrototypePush, ArrayPrototypeSplice, ArrayPrototypeUnshift, FunctionPrototypeBind, @@ -128,7 +127,7 @@ class AsyncHook { hook_fields[kTotals] += hook_fields[kDestroy] += +!!this[destroy_symbol]; hook_fields[kTotals] += hook_fields[kPromiseResolve] += +!!this[promise_resolve_symbol]; - ArrayPrototypePush(hooks_array, this); + hooks_array[hooks_array.length] = this; if (prev_kTotals === 0 && hook_fields[kTotals] > 0) { enableHooks(); diff --git a/lib/child_process.js b/lib/child_process.js index 5ceed97b57b3..267a3c12c868 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -475,7 +475,7 @@ function execFile(file, args, options, callback) { child.stdout.on('data', function onChildStdout(chunk) { // Do not need to count the length if (options.maxBuffer === Infinity) { - ArrayPrototypePush(_stdout, chunk); + _stdout[_stdout.length] = chunk; return; } const encoding = child.stdout.readableEncoding; @@ -493,7 +493,7 @@ function execFile(file, args, options, callback) { ex = new ERR_CHILD_PROCESS_STDIO_MAXBUFFER('stdout'); kill(); } else { - ArrayPrototypePush(_stdout, chunk); + _stdout[_stdout.length] = chunk; } }); } @@ -505,7 +505,7 @@ function execFile(file, args, options, callback) { child.stderr.on('data', function onChildStderr(chunk) { // Do not need to count the length if (options.maxBuffer === Infinity) { - ArrayPrototypePush(_stderr, chunk); + _stderr[_stderr.length] = chunk; return; } const encoding = child.stderr.readableEncoding; @@ -522,7 +522,7 @@ function execFile(file, args, options, callback) { ex = new ERR_CHILD_PROCESS_STDIO_MAXBUFFER('stderr'); kill(); } else { - ArrayPrototypePush(_stderr, chunk); + _stderr[_stderr.length] = chunk; } }); } @@ -782,7 +782,7 @@ function normalizeSpawnArguments(file, args, options) { let envKeys = []; // Prototype values are intentionally included. for (const key in env) { - ArrayPrototypePush(envKeys, key); + envKeys[envKeys.length] = key; } if (process.platform === 'win32') { @@ -807,7 +807,7 @@ function normalizeSpawnArguments(file, args, options) { if (value !== undefined) { validateArgumentNullCheck(key, `options.env['${key}']`); validateArgumentNullCheck(value, `options.env['${key}']`); - ArrayPrototypePush(envPairs, `${key}=${value}`); + envPairs[envPairs.length] = `${key}=${value}`; } } } @@ -849,7 +849,7 @@ function dedupeWindowsEnvPairs(envPairs) { const uppercaseKey = StringPrototypeToUpperCase(keyed[i].key); if (sawKey.has(uppercaseKey)) continue; sawKey.add(uppercaseKey); - ArrayPrototypePush(result, keyed[i].pair); + result[result.length] = keyed[i].pair; } return result; } diff --git a/lib/dgram.js b/lib/dgram.js index 653cf6a26305..f7fc4b324fe3 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -688,7 +688,7 @@ function enqueue(self, toEnqueue) { self.once(EventEmitter.errorMonitor, onListenError); self.once('listening', onListenSuccess); } - ArrayPrototypePush(state.queue, toEnqueue); + state.queue[state.queue.length] = toEnqueue; } diff --git a/lib/dns.js b/lib/dns.js index cd0c5f48b9b6..cb7f3bbd1828 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -23,7 +23,6 @@ const { Array, - ArrayPrototypePush, ObjectDefineProperties, ObjectDefineProperty, SafeMap, @@ -210,7 +209,7 @@ function lookup(hostname, options, callback) { let inflight = inflightLookups.get(key); if (inflight) { // Piggyback on existing in-flight request. - ArrayPrototypePush(inflight, waiter); + inflight[inflight.length] = waiter; return {}; } diff --git a/lib/domain.js b/lib/domain.js index caf97983b8f8..39f82237a29c 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -392,7 +392,7 @@ Domain.prototype.enter = function() { // to push it onto the stack so that we can pop it later. const currentStore = getDomainStore() || { domain: null, stack: [] }; const newStack = ArrayPrototypeSlice(currentStore.stack); - ArrayPrototypePush(newStack, this); + newStack[newStack.length] = this; setDomainStore({ domain: this, stack: newStack }); exports.active = this; currentDomain = this; @@ -472,7 +472,7 @@ Domain.prototype.remove = function(ee) { function runInDomain(domain, thisArg, fn, args) { const currentStore = getDomainStore() || { domain: null, stack: [] }; const newStack = ArrayPrototypeSlice(currentStore.stack); - ArrayPrototypePush(newStack, domain); + newStack[newStack.length] = domain; const previousDomain = currentDomain; const previousStack = currentStack; diff --git a/lib/https.js b/lib/https.js index 38623d258a20..9095a081126d 100644 --- a/lib/https.js +++ b/lib/https.js @@ -25,7 +25,6 @@ const { ArrayBufferIsView, ArrayIsArray, ArrayPrototypeIndexOf, - ArrayPrototypePush, ArrayPrototypeShift, ArrayPrototypeSplice, ArrayPrototypeUnshift, @@ -728,7 +727,7 @@ Agent.prototype._cacheSession = function _cacheSession(key, session) { delete this._sessionCache.map[oldKey]; } - ArrayPrototypePush(this._sessionCache.list, key); + this._sessionCache.list[this._sessionCache.list.length] = key; this._sessionCache.map[key] = session; }; diff --git a/lib/internal/bench_runner/benchmark.js b/lib/internal/bench_runner/benchmark.js index 114feb388172..69417a24d15a 100644 --- a/lib/internal/bench_runner/benchmark.js +++ b/lib/internal/bench_runner/benchmark.js @@ -3,7 +3,6 @@ const { ArrayIsArray, ArrayPrototypeJoin, - ArrayPrototypePush, ArrayPrototypeReverse, ArrayPrototypeSlice, ArrayPrototypeSort, @@ -101,7 +100,7 @@ function canonicalizeTags(tags, parentTags = kEmptyTags) { const tag = StringPrototypeToLowerCase(tags[i]); if (!seen.has(tag)) { seen.add(tag); - ArrayPrototypePush(result, tag); + result[result.length] = tag; } } return ObjectFreeze(result); @@ -128,7 +127,7 @@ function canonicalizeDiagnosticChannels( } if (!seen.has(name)) { seen.add(name); - ArrayPrototypePush(result, name); + result[result.length] = name; } } return ObjectFreeze(result); @@ -187,10 +186,10 @@ function createLocation(loc, fallbackFile) { function getNamePath(parent, name) { const path = []; for (let current = parent; current?.parent !== null; current = current.parent) { - ArrayPrototypePush(path, current.name); + path[path.length] = current.name; } ArrayPrototypeReverse(path); - ArrayPrototypePush(path, name); + path[path.length] = name; return path; } @@ -518,7 +517,7 @@ function summarizeSamples(samples) { let max = -Infinity; for (let i = 0; i < samples.length; i++) { const rate = samples[i].rate; - ArrayPrototypePush(rates, rate); + rates[rates.length] = rate; min = MathMin(min, rate); max = MathMax(max, rate); } diff --git a/lib/internal/bench_runner/benchmarks_stream.js b/lib/internal/bench_runner/benchmarks_stream.js index 3e3a86dd1578..76317b74a9cf 100644 --- a/lib/internal/bench_runner/benchmarks_stream.js +++ b/lib/internal/bench_runner/benchmarks_stream.js @@ -234,7 +234,7 @@ class BenchmarksStream extends Readable { } if (!this.#blocked) return PromiseResolve(); const waiter = PromiseWithResolvers(); - ArrayPrototypePush(this.#drainWaiters, waiter); + this.#drainWaiters[this.#drainWaiters.length] = waiter; return waiter.promise; } diff --git a/lib/internal/bench_runner/cli.js b/lib/internal/bench_runner/cli.js index 4993b44face4..cc4f3da03b78 100644 --- a/lib/internal/bench_runner/cli.js +++ b/lib/internal/bench_runner/cli.js @@ -239,10 +239,10 @@ function parseCommandLine() { if (!isChild) { if (reporters.length === 0 && destinations.length === 0) { - ArrayPrototypePush(reporters, 'spec'); + reporters[reporters.length] = 'spec'; } if (reporters.length === 1 && destinations.length === 0) { - ArrayPrototypePush(destinations, 'stdout'); + destinations[destinations.length] = 'stdout'; } if (reporters.length !== destinations.length) { throw new ERR_INVALID_ARG_VALUE( @@ -326,7 +326,7 @@ async function setupReporters(stream, reporters, destinations) { ), undefined, (error) => { state.error ??= error; }); - ArrayPrototypePush(state.pending, pending); + state.pending[state.pending.length] = pending; } } catch (error) { stream.destroy(); @@ -748,7 +748,7 @@ function getInheritedChildArgs() { ); ArrayPrototypePushApply(args, unknownExecArgv); // Option serialization omits port 0, which would otherwise become 9229. - if (process.debugPort === 0) ArrayPrototypePush(args, '--inspect-port=0'); + if (process.debugPort === 0) args[args.length] = '--inspect-port=0'; return args; } @@ -758,18 +758,18 @@ function getChildArgs(path, options) { ArrayPrototypePush( args, '--experimental-bench', '--bench', '--bench-isolation=none'); if (options.gc !== undefined) { - ArrayPrototypePush(args, `--bench-gc=${options.gc}`); - if (options.gc !== 'none') ArrayPrototypePush(args, '--expose-gc'); + args[args.length] = `--bench-gc=${options.gc}`; + if (options.gc !== 'none') args[args.length] = '--expose-gc'; } if (options.namePatternSource.length > 0) { ArrayPrototypePush( args, `--bench-name-pattern=${options.namePatternSource}`); } if (options.samples !== undefined) { - ArrayPrototypePush(args, `--bench-samples=${options.samples}`); + args[args.length] = `--bench-samples=${options.samples}`; } if (options.warmup !== undefined) { - ArrayPrototypePush(args, `--bench-warmup=${options.warmup}`); + args[args.length] = `--bench-warmup=${options.warmup}`; } ArrayPrototypePush(args, '--', resolve(options.cwd, path)); return args; @@ -1194,7 +1194,7 @@ function runFile(path, options = kEmptyObject) { `options.execArgv[${i}]`, arg, 'must be followed by a value'); } - ArrayPrototypePush(childExecArgv, arg); + childExecArgv[childExecArgv.length] = arg; i++; const value = execArgv[i]; validateStringWithoutNullBytes(value, `options.execArgv[${i}]`); @@ -1203,7 +1203,7 @@ function runFile(path, options = kEmptyObject) { `options.execArgv[${i}]`, value, 'must not be empty'); } - ArrayPrototypePush(childExecArgv, value); + childExecArgv[childExecArgv.length] = value; continue; } if (!StringPrototypeStartsWith(arg, '--') && @@ -1212,7 +1212,7 @@ function runFile(path, options = kEmptyObject) { `options.execArgv[${i}]`, arg, 'must not use = with a short option'); } - ArrayPrototypePush(childExecArgv, arg); + childExecArgv[childExecArgv.length] = arg; } if (ArrayPrototypeFilter(childExecArgv, filterExecArgv).length !== childExecArgv.length) { diff --git a/lib/internal/bench_runner/environment.js b/lib/internal/bench_runner/environment.js index 17e349c342a3..6a0b1ef197a2 100644 --- a/lib/internal/bench_runner/environment.js +++ b/lib/internal/bench_runner/environment.js @@ -1,7 +1,6 @@ 'use strict'; const { - ArrayPrototypePush, ArrayPrototypeSlice, } = primordials; @@ -20,7 +19,7 @@ function groupCpus(cpus) { } if (group === undefined) { group = { __proto__: null, model, count: 0 }; - ArrayPrototypePush(groups, group); + groups[groups.length] = group; } group.count++; } diff --git a/lib/internal/bench_runner/harness.js b/lib/internal/bench_runner/harness.js index e9afe90ce508..3b0069a379e3 100644 --- a/lib/internal/bench_runner/harness.js +++ b/lib/internal/bench_runner/harness.js @@ -221,7 +221,7 @@ class Harness { normalized.fn, overrides.loc, ); - ArrayPrototypePush(parent.children, benchmark); + parent.children[parent.children.length] = benchmark; this.#schedule(); return parent.isRoot ? benchmark.completion.promise : PromiseResolve(); } @@ -238,7 +238,7 @@ class Harness { normalized.fn, overrides.loc, ); - ArrayPrototypePush(parent.children, suite); + parent.children[parent.children.length] = suite; this.#buildSuite(suite); this.#schedule(); return parent.isRoot ? suite.completion.promise : PromiseResolve(); @@ -277,7 +277,7 @@ class Harness { suite.buildError = error; }, ); - ArrayPrototypePush(this.#buildPromises, suite.buildPromise); + this.#buildPromises[this.#buildPromises.length] = suite.buildPromise; } configure(options = kEmptyObject) { @@ -446,7 +446,7 @@ class Harness { async #emitPlans() { const benchmarks = []; this.#walk(this.root, (node) => { - if (node instanceof Bench) ArrayPrototypePush(benchmarks, node); + if (node instanceof Bench) benchmarks[benchmarks.length] = node; }); for (let i = 0; i < benchmarks.length; i++) { const benchmark = benchmarks[i]; @@ -686,7 +686,7 @@ class Harness { #getHookSuites(benchmark) { const suites = []; for (let current = benchmark.parent; current !== null; current = current.parent) { - ArrayPrototypePush(suites, current); + suites[suites.length] = current; } ArrayPrototypeReverse(suites); return suites; @@ -704,11 +704,11 @@ class Harness { async #runWithStop(benchmark, controller, callback, deadline) { const signals = []; if (this.outerSignal !== undefined) { - ArrayPrototypePush(signals, this.outerSignal); + signals[signals.length] = this.outerSignal; } if (benchmark.outerSignal !== undefined && benchmark.outerSignal !== this.outerSignal) { - ArrayPrototypePush(signals, benchmark.outerSignal); + signals[signals.length] = benchmark.outerSignal; } for (let i = 0; i < signals.length; i++) { @@ -982,7 +982,7 @@ class Harness { throw controller.signal.reason; } if (i >= warmup) { - ArrayPrototypePush(samples, outcome.sample); + samples[samples.length] = outcome.sample; } } diff --git a/lib/internal/bench_runner/reporter/spec.js b/lib/internal/bench_runner/reporter/spec.js index cf3ba088548d..ac87bff9d310 100644 --- a/lib/internal/bench_runner/reporter/spec.js +++ b/lib/internal/bench_runner/reporter/spec.js @@ -87,9 +87,9 @@ function formatEnvironment(environment) { const groups = []; for (let i = 0; i < cpus.length; i++) { - ArrayPrototypePush(groups, `${cpus[i].count} x ${cpus[i].model}`); + groups[groups.length] = `${cpus[i].count} x ${cpus[i].model}`; } - if (groups.length === 0) ArrayPrototypePush(groups, 'unknown'); + if (groups.length === 0) groups[groups.length] = 'unknown'; output += `cpu: ${ArrayPrototypeJoin(groups, ', ')} ` + `(available parallelism: ${environment.availableParallelism})\n`; @@ -117,14 +117,14 @@ function formatWarning(summary) { const warnings = []; if (NumberIsFinite(summary.coefficientOfVariation) && summary.coefficientOfVariation > 0.05) { - ArrayPrototypePush(warnings, 'noisy'); + warnings[warnings.length] = 'noisy'; } if (NumberIsFinite(summary.skewness) && MathAbs(summary.skewness) > 1) { - ArrayPrototypePush(warnings, 'skewed'); + warnings[warnings.length] = 'skewed'; } if (NumberIsFinite(summary.median) && summary.median >= kImplausibleRate) { - ArrayPrototypePush(warnings, 'implausible'); + warnings[warnings.length] = 'implausible'; } return ArrayPrototypeJoin(warnings, ', '); } @@ -180,10 +180,10 @@ class SpecReporter extends Transform { this.#environment ??= collectEnvironment(); switch (type) { case 'bench:complete': - ArrayPrototypePush(this.#results, data); + this.#results[this.#results.length] = data; break; case 'bench:diagnostic': - ArrayPrototypePush(this.#diagnostics, data); + this.#diagnostics[this.#diagnostics.length] = data; break; case 'bench:summary': this.#reported = true; diff --git a/lib/internal/blob.js b/lib/internal/blob.js index aea19d6e7471..1e89e3e0fb8f 100644 --- a/lib/internal/blob.js +++ b/lib/internal/blob.js @@ -3,7 +3,6 @@ const { ArrayBufferPrototypeGetByteLength, ArrayBufferPrototypeGetDetached, - ArrayPrototypePush, DataViewPrototypeGetBuffer, DataViewPrototypeGetByteLength, DataViewPrototypeGetByteOffset, @@ -528,7 +527,7 @@ function getBlobDataSync(blob) { return; } if (buffer !== undefined) - ArrayPrototypePush(buffers, buffer); + buffers[buffers.length] = buffer; }); if (!sync) { // The data is not available synchronously. @@ -708,7 +707,7 @@ async function* createBlobReaderIterable(reader, options = kEmptyObject) { break; } const chunk = new Uint8Array(pullResult.buffer); - ArrayPrototypePush(batch, chunk); + batch[batch.length] = chunk; // Stop collecting once the batch is large enough. The byte budget is // the primary limit; the chunk count is a secondary bound so that a // long run of tiny chunks cannot produce an unwieldy array. diff --git a/lib/internal/crypto/util.js b/lib/internal/crypto/util.js index 52445eab767c..9c5a38461c57 100644 --- a/lib/internal/crypto/util.js +++ b/lib/internal/crypto/util.js @@ -5,7 +5,6 @@ const { ArrayBufferPrototypeGetByteLength, ArrayBufferPrototypeGetDetached, ArrayPrototypeIncludes, - ArrayPrototypePush, ArrayPrototypeSlice, BigInt, DataViewPrototypeGetBuffer, @@ -1174,7 +1173,7 @@ function getUsagesFromMask(mask) { const result = []; for (let n = 0; n < kCanonicalUsageOrder.length; n++) { if (mask & (1 << n)) - ArrayPrototypePush(result, kCanonicalUsageOrder[n]); + result[result.length] = kCanonicalUsageOrder[n]; } return result; } diff --git a/lib/internal/crypto/webidl.js b/lib/internal/crypto/webidl.js index 63d086a7698a..5121794b309c 100644 --- a/lib/internal/crypto/webidl.js +++ b/lib/internal/crypto/webidl.js @@ -156,8 +156,8 @@ function createAlgorithmDictionaryConverter(name, dictionaries) { } ArrayPrototypePush(dictionary, { ...member, validator: undefined }); } - ArrayPrototypePush(members, dictionary); - ArrayPrototypePush(fullMembers, dictionary); + members[members.length] = dictionary; + fullMembers[fullMembers.length] = dictionary; } validators[name] = (algorithm) => { for (let i = 0; i < checks.length; i++) { diff --git a/lib/internal/crypto/x509_generation.js b/lib/internal/crypto/x509_generation.js index dd890f4870a5..1f1a46e9182f 100644 --- a/lib/internal/crypto/x509_generation.js +++ b/lib/internal/crypto/x509_generation.js @@ -241,7 +241,7 @@ function normalizeDistinguishedName(name, path) { ArrayPrototypePush(normalized, normalizeNameAttribute( attributes[j], ArrayIsArray(entry) ? `${entryPath}[${j}]` : entryPath)); } - ArrayPrototypePush(rdns, normalized); + rdns[rdns.length] = normalized; } return rdns; } @@ -371,7 +371,7 @@ function normalizeExtendedKeyUsage(usages, path) { `${path}[${i}]`, value, 'must not be duplicated'); } seen.add(oid); - ArrayPrototypePush(normalized, oid); + normalized[normalized.length] = oid; } return normalized; } @@ -458,7 +458,7 @@ function normalizeExtensions(extensions, arrayPath = 'options.extensions') { throw new ERR_INVALID_ARG_VALUE(`${path}.type`, type); } - ArrayPrototypePush(output, normalized); + output[output.length] = normalized; } return output; } diff --git a/lib/internal/debugger/inspect_repl.js b/lib/internal/debugger/inspect_repl.js index 69ca174dd241..34c3a10da166 100644 --- a/lib/internal/debugger/inspect_repl.js +++ b/lib/internal/debugger/inspect_repl.js @@ -10,7 +10,6 @@ const { ArrayPrototypeIndexOf, ArrayPrototypeJoin, ArrayPrototypeMap, - ArrayPrototypePush, ArrayPrototypeSlice, ArrayPrototypeSome, ArrayPrototypeSplice, @@ -257,7 +256,7 @@ class ObjectPreview { return `${prop.name}: ${value}`; }); if (this.overflow) { - ArrayPrototypePush(props, '...'); + props[props.length] = '...'; } const singleLine = ArrayPrototypeJoin(props, ', '); const propString = singleLine.length > 60 ? ArrayPrototypeJoin(props, ',\n ') : singleLine; @@ -451,7 +450,7 @@ function createRepl(inspector) { static createAndRegister({ profile }) { const p = new Profile(profile); - ArrayPrototypePush(profiles, p); + profiles[profiles.length] = p; return p; } @@ -722,7 +721,7 @@ function createRepl(inspector) { return false; }); if (!isExisting) { - ArrayPrototypePush(knownBreakpoints, { breakpointId, location }); + knownBreakpoints[knownBreakpoints.length] = { breakpointId, location }; } } @@ -1108,7 +1107,7 @@ function createRepl(inspector) { watch(expr) { validateString(expr, 'expression'); - ArrayPrototypePush(watchedExpressions, expr); + watchedExpressions[watchedExpressions.length] = expr; }, unwatch(expr) { diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 786fc7e275eb..dafeb96740c2 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -173,7 +173,7 @@ const aggregateTwoErrors = (innerError, outerError) => { if (innerError && outerError && innerError !== outerError) { if (ArrayIsArray(outerError.errors)) { // If `outerError` is already an `AggregateError`. - ArrayPrototypePush(outerError.errors, innerError); + outerError.errors[outerError.errors.length] = innerError; return outerError; } let err; @@ -1442,11 +1442,11 @@ E('ERR_INVALID_ARG_TYPE', if (ArrayPrototypeIncludes(kTypes, value)) { ArrayPrototypePush(types, StringPrototypeToLowerCase(value)); } else if (RegExpPrototypeExec(classRegExp, value) !== null) { - ArrayPrototypePush(instances, value); + instances[instances.length] = value; } else { assert(value !== 'object', 'The value "object" should be written as "Object"'); - ArrayPrototypePush(other, value); + other[other.length] = value; } } @@ -1456,7 +1456,7 @@ E('ERR_INVALID_ARG_TYPE', const pos = ArrayPrototypeIndexOf(types, 'object'); if (pos !== -1) { ArrayPrototypeSplice(types, pos, 1); - ArrayPrototypePush(instances, 'Object'); + instances[instances.length] = 'Object'; } } diff --git a/lib/internal/fs/dir.js b/lib/internal/fs/dir.js index 32050f31ae6d..e58cb0a8d8d5 100644 --- a/lib/internal/fs/dir.js +++ b/lib/internal/fs/dir.js @@ -93,7 +93,7 @@ class Dir { if (result !== null) { this.#processReadResult(path, result); if (result.length > 0) { - ArrayPrototypePush(this.#handlerQueue, handler); + this.#handlerQueue[this.#handlerQueue.length] = handler; } } else { handle.close(); @@ -203,7 +203,7 @@ class Dir { return; } - ArrayPrototypePush(this.#handlerQueue, { handle, path }); + this.#handlerQueue[this.#handlerQueue.length] = { handle, path }; } readSync() { diff --git a/lib/internal/fs/watchers.js b/lib/internal/fs/watchers.js index 944d469bd19b..68d5899630bc 100644 --- a/lib/internal/fs/watchers.js +++ b/lib/internal/fs/watchers.js @@ -102,7 +102,7 @@ function createIgnoreMatcher(ignore) { ArrayPrototypePush(compiled, (filename) => RegExpPrototypeExec(matcher, filename) !== null); } else { // Function - ArrayPrototypePush(compiled, matcher); + compiled[compiled.length] = matcher; } } @@ -420,7 +420,7 @@ async function* watch(filename, options = kEmptyObject) { }); error.filename = filename; handle.close(); - ArrayPrototypePush(queue, error); + queue[queue.length] = error; resolve(); return; } @@ -429,7 +429,7 @@ async function* watch(filename, options = kEmptyObject) { return; } if (queue.length < maxQueue) { - ArrayPrototypePush(queue, { __proto__: null, eventType, filename }); + queue[queue.length] = { __proto__: null, eventType, filename }; resolve(); } else if (overflow === 'error') { queue.length = 0; diff --git a/lib/internal/main/watch_mode.js b/lib/internal/main/watch_mode.js index 1cb73be912e8..dcdd05bd6c53 100644 --- a/lib/internal/main/watch_mode.js +++ b/lib/internal/main/watch_mode.js @@ -3,7 +3,6 @@ const { ArrayPrototypeForEach, ArrayPrototypeJoin, ArrayPrototypeMap, - ArrayPrototypePush, ArrayPrototypePushApply, ArrayPrototypeSlice, StringPrototypeIncludes, @@ -93,7 +92,7 @@ for (let i = 0; i < process.execArgv.length; i++) { if (arg === '--experimental-default-config-file') { continue; } - ArrayPrototypePush(argsWithoutWatchOptions, process.execArgv[i]); + argsWithoutWatchOptions[argsWithoutWatchOptions.length] = process.execArgv[i]; } ArrayPrototypePushApply(argsWithoutWatchOptions, kCommand); @@ -131,9 +130,9 @@ if (kNodeOptions != null) { if (StringPrototypeIncludes(part, ' ') || StringPrototypeIncludes(part, '"')) { const escaped = StringPrototypeReplaceAll( StringPrototypeReplaceAll(part, '\\', '\\\\'), '"', '\\"'); - ArrayPrototypePush(keep, `"${escaped}"`); + keep[keep.length] = `"${escaped}"`; } else { - ArrayPrototypePush(keep, part); + keep[keep.length] = part; } } cleanNodeOptions = ArrayPrototypeJoin(keep, ' '); diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index f9c4a62f023a..8e731579dfd9 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -1007,7 +1007,7 @@ if (isWindows) { } // Append /node_modules to handle root paths. - ArrayPrototypePush(paths, '/node_modules'); + paths[paths.length] = '/node_modules'; return paths; }; @@ -1548,7 +1548,7 @@ Module._resolveFilename = function(request, parent, isMain, options) { for (let j = 0; j < lookupPaths.length; j++) { if (!ArrayPrototypeIncludes(paths, lookupPaths[j])) { - ArrayPrototypePush(paths, lookupPaths[j]); + paths[paths.length] = lookupPaths[j]; } } } diff --git a/lib/internal/modules/customization_hooks.js b/lib/internal/modules/customization_hooks.js index c3d1970243fd..54557b30f0bd 100644 --- a/lib/internal/modules/customization_hooks.js +++ b/lib/internal/modules/customization_hooks.js @@ -2,7 +2,6 @@ const { ArrayPrototypeFindIndex, - ArrayPrototypePush, ArrayPrototypeSplice, ObjectAssign, ObjectFreeze, @@ -76,10 +75,10 @@ class ModuleHooks { this.load = load; if (resolve) { - ArrayPrototypePush(resolveHooks, this); + resolveHooks[resolveHooks.length] = this; } if (load) { - ArrayPrototypePush(loadHooks, this); + loadHooks[loadHooks.length] = this; } ObjectFreeze(this); @@ -197,7 +196,7 @@ function buildHooks(hooks, name, defaultStep, validate, mergedContext) { const chain = [wrapHook(0, defaultStep)]; for (let i = 0; i < hooks.length; ++i) { const wrappedHook = wrapHook(i + 1, hooks[i][name], chain[i]); - ArrayPrototypePush(chain, wrappedHook); + chain[chain.length] = wrappedHook; } return chain[chain.length - 1]; } diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js index 583b6d1fe91d..ea88b0fb7498 100644 --- a/lib/internal/modules/esm/translators.js +++ b/lib/internal/modules/esm/translators.js @@ -1,7 +1,6 @@ 'use strict'; const { - ArrayPrototypePush, FunctionPrototypeCall, JSONParse, ObjectAssign, @@ -230,10 +229,10 @@ function createCJSModuleWrap(url, translateContext, parentURL) { const wrapperNames = [...exportNames]; if (!exportNames.has('default')) { - ArrayPrototypePush(wrapperNames, 'default'); + wrapperNames[wrapperNames.length] = 'default'; } if (!exportNames.has('module.exports')) { - ArrayPrototypePush(wrapperNames, 'module.exports'); + wrapperNames[wrapperNames.length] = 'module.exports'; } if (isMain) { @@ -599,7 +598,7 @@ translators.set('wasm', function(url, translateContext) { const wasmGlobalImports = []; for (const impt of WebAssembly.Module.imports(compiled)) { if (impt.kind === 'global') { - ArrayPrototypePush(wasmGlobalImports, impt); + wasmGlobalImports[wasmGlobalImports.length] = impt; } // Prefix reservations per https://webassembly.github.io/esm-integration/js-api/index.html#parse-a-webassembly-module. if (impt.module.startsWith('wasm-js:')) { diff --git a/lib/internal/modules/helpers.js b/lib/internal/modules/helpers.js index e30b892ad5eb..5f30b8da7c64 100644 --- a/lib/internal/modules/helpers.js +++ b/lib/internal/modules/helpers.js @@ -2,7 +2,6 @@ const { ArrayPrototypeForEach, - ArrayPrototypePush, MapPrototypeForEach, MapPrototypeGet, ObjectDefineProperty, @@ -663,7 +662,7 @@ function getRequireStack(parent) { cursor; // TODO(joyeecheung): it makes more sense to use kLastModuleParent here. cursor = cursor[kFirstModuleParent]) { - ArrayPrototypePush(requireStack, cursor.filename || cursor.id); + requireStack[requireStack.length] = cursor.filename || cursor.id; } return requireStack; } diff --git a/lib/internal/perf/observe.js b/lib/internal/perf/observe.js index 4a1931dd299e..82bea6163f44 100644 --- a/lib/internal/perf/observe.js +++ b/lib/internal/perf/observe.js @@ -359,7 +359,7 @@ class PerformanceObserver { [kMaybeBuffer](entry) { if (!this.#entryTypes.has(entry.entryType)) return; - ArrayPrototypePush(this.#buffer, entry); + this.#buffer[this.#buffer.length] = entry; kPending.add(this); if (kPending.size) queuePending(); @@ -428,7 +428,7 @@ function bufferUserTiming(entry) { return; } - ArrayPrototypePush(buffer, entry); + buffer[buffer.length] = entry; const count = buffer.length; if (count > kPerformanceEntryBufferWarnSize && @@ -457,7 +457,7 @@ function bufferUserTiming(entry) { */ function bufferResourceTiming(entry) { if (resourceTimingBuffer.length < resourceTimingBufferSizeLimit && !resourceTimingBufferFullPending) { - ArrayPrototypePush(resourceTimingBuffer, entry); + resourceTimingBuffer[resourceTimingBuffer.length] = entry; return; } @@ -486,7 +486,7 @@ function bufferResourceTiming(entry) { }); } - ArrayPrototypePush(resourceTimingSecondaryBuffer, entry); + resourceTimingSecondaryBuffer[resourceTimingSecondaryBuffer.length] = entry; } // https://w3c.github.io/resource-timing/#dom-performance-setresourcetimingbuffersize diff --git a/lib/internal/process/permission.js b/lib/internal/process/permission.js index f3ed889e8c19..570abaef25ff 100644 --- a/lib/internal/process/permission.js +++ b/lib/internal/process/permission.js @@ -1,7 +1,6 @@ 'use strict'; const { - ArrayPrototypePush, ObjectFreeze, StringPrototypeStartsWith, } = primordials; @@ -88,7 +87,7 @@ module.exports = ObjectFreeze({ ]; if (_ffi) { - ArrayPrototypePush(flags, '--allow-ffi'); + flags[flags.length] = '--allow-ffi'; } return flags; diff --git a/lib/internal/promise_hooks.js b/lib/internal/promise_hooks.js index 7a29229ddbe5..fe07e30002f5 100644 --- a/lib/internal/promise_hooks.js +++ b/lib/internal/promise_hooks.js @@ -30,7 +30,7 @@ function initAll(promise, parent) { try { init(promise, parent); } catch (err) { - ArrayPrototypePush(exceptions, err); + exceptions[exceptions.length] = err; } } @@ -51,7 +51,7 @@ function makeRunHook(list) { try { hook(promise); } catch (err) { - ArrayPrototypePush(exceptions, err); + exceptions[exceptions.length] = err; } } @@ -91,7 +91,7 @@ function makeUseHook(name) { const list = hooks[name]; return (hook) => { validatePlainFunction(hook, `${name}Hook`); - ArrayPrototypePush(list, hook); + list[list.length] = hook; update(); return FunctionPrototypeBind(stop, null, list, hook); }; diff --git a/lib/internal/readline/promises.js b/lib/internal/readline/promises.js index 51585029557e..c5a149cc72ba 100644 --- a/lib/internal/readline/promises.js +++ b/lib/internal/readline/promises.js @@ -2,7 +2,6 @@ const { ArrayPrototypeJoin, - ArrayPrototypePush, Promise, } = primordials; @@ -47,7 +46,7 @@ class Readline { const data = y == null ? CSI`${x + 1}G` : CSI`${y + 1};${x + 1}H`; if (this.#autoCommit) process.nextTick(() => this.#stream.write(data)); - else ArrayPrototypePush(this.#todo, data); + else this.#todo[this.#todo.length] = data; return this; } @@ -77,7 +76,7 @@ class Readline { data += CSI`${dy}B`; } if (this.#autoCommit) process.nextTick(() => this.#stream.write(data)); - else ArrayPrototypePush(this.#todo, data); + else this.#todo[this.#todo.length] = data; } return this; } @@ -98,7 +97,7 @@ class Readline { dir > 0 ? kClearToLineEnd : kClearLine; if (this.#autoCommit) process.nextTick(() => this.#stream.write(data)); - else ArrayPrototypePush(this.#todo, data); + else this.#todo[this.#todo.length] = data; return this; } @@ -110,7 +109,7 @@ class Readline { if (this.#autoCommit) { process.nextTick(() => this.#stream.write(kClearScreenDown)); } else { - ArrayPrototypePush(this.#todo, kClearScreenDown); + this.#todo[this.#todo.length] = kClearScreenDown; } return this; } diff --git a/lib/internal/repl/completion.js b/lib/internal/repl/completion.js index a0af25993433..f67f6899940e 100644 --- a/lib/internal/repl/completion.js +++ b/lib/internal/repl/completion.js @@ -118,7 +118,7 @@ function finalizeCompletions(completionGroups, filter, completeOn) { StringPrototypeToLocaleLowerCase(str), lowerCaseFilter), ); if (filteredGroup.length) { - ArrayPrototypePush(newCompletionGroups, filteredGroup); + newCompletionGroups[newCompletionGroups.length] = filteredGroup; } }); completionGroups = newCompletionGroups; @@ -242,7 +242,7 @@ function completeModuleSpecifier(repl, match, options) { if (completeOn === '.') { ArrayPrototypePush(group, './', '../'); } else if (completeOn === '..') { - ArrayPrototypePush(group, '../'); + group[group.length] = '../'; } else if (RegExpPrototypeExec(relativePathRE, completeOn) !== null) { paths = [process.cwd()]; } else { @@ -266,21 +266,21 @@ function completeModuleSpecifier(repl, match, options) { if (ArrayPrototypeIncludes(extensions, extension)) { const completion = formatFile(subdir, name, extension); if (completion !== null) { - ArrayPrototypePush(group, completion); + group[group.length] = completion; } } return; } - ArrayPrototypePush(group, `${subdir}${name}/`); + group[group.length] = `${subdir}${name}/`; if (listsDirectoryIndex(subdir, isInNodeModules) && hasIndexFile(path.resolve(dir, name), indexes)) { - ArrayPrototypePush(group, `${subdir}${name}`); + group[group.length] = `${subdir}${name}`; } }); }); if (group.length) { - ArrayPrototypePush(completionGroups, group); + completionGroups[completionGroups.length] = group; } } @@ -359,7 +359,7 @@ async function completeGlobalScope(repl, filter) { const lexicalNames = await getReplInspector(repl).globalLexicalScopeNames(repl[kContextId]); - ArrayPrototypePush(completionGroups, lexicalNames); + completionGroups[completionGroups.length] = lexicalNames; let contextProto = repl.context; while ((contextProto = ObjectGetPrototypeOf(contextProto)) !== null) { @@ -372,7 +372,7 @@ async function completeGlobalScope(repl, filter) { // `getGlobalBuiltins()` is a `SafeSet`, not an Array-like. ArrayPrototypePush(contextOwnNames, ...getGlobalBuiltins()); } - ArrayPrototypePush(completionGroups, contextOwnNames); + completionGroups[completionGroups.length] = contextOwnNames; if (filter !== '') { addCommonWords(completionGroups); @@ -468,10 +468,10 @@ async function completeMemberExpression(inspector, receiver, chaining, contextId const groups = []; if (own.length) { - ArrayPrototypePush(groups, own); + groups[groups.length] = own; } if (inherited.length) { - ArrayPrototypePush(groups, inherited); + groups[groups.length] = inherited; } return groups; } finally { @@ -565,14 +565,14 @@ function endsInsideStringLiteral(code) { } else if (ch === '`') { ArrayPrototypePop(stack); } else if (ch === '$' && code[i + 1] === '{') { - ArrayPrototypePush(stack, '{'); // Enter a `${ ... }` substitution. + stack[stack.length] = '{'; // Enter a `${ ... }` substitution. i++; } } else if (ch === "'" || ch === '"' || ch === '`') { // Code context: a quote opens a new string or template literal. - ArrayPrototypePush(stack, ch); + stack[stack.length] = ch; } else if (ch === '{') { - ArrayPrototypePush(stack, '{'); + stack[stack.length] = '{'; } else if (ch === '}' && top === '{') { ArrayPrototypePop(stack); } diff --git a/lib/internal/streams/fast-utf8-stream.js b/lib/internal/streams/fast-utf8-stream.js index 004ff14781f1..af7026615a2a 100644 --- a/lib/internal/streams/fast-utf8-stream.js +++ b/lib/internal/streams/fast-utf8-stream.js @@ -985,8 +985,8 @@ class Utf8Stream extends EventEmitter { } if (this.#bufs.length === 0) { - ArrayPrototypePush(this.#bufs, []); - ArrayPrototypePush(this.#lens, 0); + this.#bufs[this.#bufs.length] = []; + this.#lens[this.#lens.length] = 0; } this.#actualWrite(); @@ -1019,7 +1019,7 @@ class Utf8Stream extends EventEmitter { } if (this.#bufs.length === 0) { - ArrayPrototypePush(this.#bufs, ''); + this.#bufs[this.#bufs.length] = ''; } this.#actualWrite(); @@ -1053,8 +1053,8 @@ class Utf8Stream extends EventEmitter { bufs.length === 0 || lens[lens.length - 1] + data.length > this.#maxWrite ) { - ArrayPrototypePush(bufs, [data]); - ArrayPrototypePush(lens, data.length); + bufs[bufs.length] = [data]; + lens[lens.length] = data.length; } else { ArrayPrototypePush(bufs[bufs.length - 1], data); lens[lens.length - 1] += data.length; @@ -1087,7 +1087,7 @@ class Utf8Stream extends EventEmitter { bufs.length === 0 || bufs[bufs.length - 1].length + data.length > this.#maxWrite ) { - ArrayPrototypePush(bufs, '' + data); + bufs[bufs.length] = '' + data; } else { bufs[bufs.length - 1] += data; } diff --git a/lib/internal/streams/iter/classic.js b/lib/internal/streams/iter/classic.js index c1ed8ad51f53..2b39bc927874 100644 --- a/lib/internal/streams/iter/classic.js +++ b/lib/internal/streams/iter/classic.js @@ -160,14 +160,14 @@ async function normalizeBatch(raw) { for (let i = 0; i < raw.length; i++) { const value = raw[i]; if (isUint8Array(value)) { - ArrayPrototypePush(batch, value); + batch[batch.length] = value; } else { // normalizeAsyncValue may await for async protocols (e.g. // toAsyncStreamable on yielded objects). Stream events during // the suspension are queued, not lost -- errors will surface // on the next loop iteration after this yield completes. for await (const normalized of normalizeAsyncValue(value)) { - ArrayPrototypePush(batch, normalized); + batch[batch.length] = normalized; } } } @@ -229,7 +229,7 @@ function createBatchedAsyncIterator(stream, normalize) { stream._readableState?.length > 0) { const c = stream.read(); if (c === null) break; - ArrayPrototypePush(batch, c); + batch[batch.length] = c; } if (normalize !== null) { const result = await normalize(batch); diff --git a/lib/internal/streams/iter/consumers.js b/lib/internal/streams/iter/consumers.js index 0751d2cc95f6..b1e8c5dcef96 100644 --- a/lib/internal/streams/iter/consumers.js +++ b/lib/internal/streams/iter/consumers.js @@ -563,7 +563,7 @@ function merge(...args) { const iterators = []; for (let i = 0; i < normalized.length; i++) { const iterator = normalized[i][SymbolAsyncIterator](); - ArrayPrototypePush(iterators, iterator); + iterators[iterators.length] = iterator; pendingPulls.add(iterator); PromisePrototypeThen( iterator.next(), diff --git a/lib/internal/streams/operators.js b/lib/internal/streams/operators.js index 87b82b65b56b..2bfb0714286b 100644 --- a/lib/internal/streams/operators.js +++ b/lib/internal/streams/operators.js @@ -1,7 +1,6 @@ 'use strict'; const { - ArrayPrototypePush, Boolean, MathFloor, Number, @@ -298,7 +297,7 @@ async function toArray(options) { if (options?.signal?.aborted) { throw new AbortError(undefined, { cause: options.signal.reason }); } - ArrayPrototypePush(result, val); + result[result.length] = val; } return result; } diff --git a/lib/internal/test_runner/coverage.js b/lib/internal/test_runner/coverage.js index 3d0fcde700a4..22a150177ff1 100644 --- a/lib/internal/test_runner/coverage.js +++ b/lib/internal/test_runner/coverage.js @@ -717,7 +717,7 @@ function mapRangeToLines(range, lines) { line.count = count; } - ArrayPrototypePush(mappedLines, line); + mappedLines[mappedLines.length] = line; if (line.ignore) { ignoredLines++; @@ -781,7 +781,7 @@ function mergeCoverageScripts(oldScript, newScript) { // not show up in the coverage report. Unfortunately, this also means // that the function counts in the coverage summary can never be // guaranteed to be 100% accurate. - ArrayPrototypePush(oldScript.functions, newFn); + oldScript.functions[oldScript.functions.length] = newFn; } } } diff --git a/lib/internal/test_runner/mock/mock.js b/lib/internal/test_runner/mock/mock.js index 4861f31b5f29..ea0b7e838bd7 100644 --- a/lib/internal/test_runner/mock/mock.js +++ b/lib/internal/test_runner/mock/mock.js @@ -205,7 +205,7 @@ class MockFunctionContext { * @param {object} call - The call details. */ trackCall(call) { - ArrayPrototypePush(this.#calls, call); + this.#calls[this.#calls.length] = call; } /** @@ -392,7 +392,7 @@ class MockPropertyContext { // eslint-disable-next-line no-restricted-syntax stack: new Error(), }; - ArrayPrototypePush(this.#accesses, access); + this.#accesses[this.#accesses.length] = access; return nextValue; }, set: this.mockImplementation.bind(this), @@ -434,7 +434,7 @@ class MockPropertyContext { // eslint-disable-next-line no-restricted-syntax stack: new Error(), }; - ArrayPrototypePush(this.#accesses, access); + this.#accesses[this.#accesses.length] = access; this.#value = nextValue; } diff --git a/lib/internal/test_runner/reporter/junit.js b/lib/internal/test_runner/reporter/junit.js index e5a3fa961eac..8dcdf5a88162 100644 --- a/lib/internal/test_runner/reporter/junit.js +++ b/lib/internal/test_runner/reporter/junit.js @@ -80,10 +80,10 @@ module.exports = async function* junitReporter(source) { children: [], }; if (originalSuite?.children) { - ArrayPrototypePush(originalSuite.children, currentSuite); + originalSuite.children[originalSuite.children.length] = currentSuite; } if (!currentSuite.parent) { - ArrayPrototypePush(roots, currentSuite); + roots[roots.length] = currentSuite; } } diff --git a/lib/internal/test_runner/reporter/rerun.js b/lib/internal/test_runner/reporter/rerun.js index ba2a1fe39141..930dbb7bca2a 100644 --- a/lib/internal/test_runner/reporter/rerun.js +++ b/lib/internal/test_runner/reporter/rerun.js @@ -2,7 +2,6 @@ const { ArrayPrototypeMap, - ArrayPrototypePush, JSONStringify, } = primordials; const { relative } = require('path'); @@ -29,10 +28,10 @@ function reportReruns(previousRuns, globalOptions) { hasFailedDescendant: false, }; if (originalSuite?.children) { - ArrayPrototypePush(originalSuite.children, currentSuite); + originalSuite.children[originalSuite.children.length] = currentSuite; } if (!currentSuite.parent) { - ArrayPrototypePush(roots, currentSuite); + roots[roots.length] = currentSuite; } } @@ -80,7 +79,7 @@ function reportReruns(previousRuns, globalOptions) { } } - ArrayPrototypePush(previousRuns, obj); + previousRuns[previousRuns.length] = obj; writeFileSync(globalOptions.rerunFailuresFilePath, JSONStringify(previousRuns, null, 2), 'utf8'); }; }; diff --git a/lib/internal/test_runner/reporter/tap.js b/lib/internal/test_runner/reporter/tap.js index 2bacba167570..afd5cb3d2b80 100644 --- a/lib/internal/test_runner/reporter/tap.js +++ b/lib/internal/test_runner/reporter/tap.js @@ -2,7 +2,6 @@ const { ArrayPrototypeForEach, ArrayPrototypeJoin, - ArrayPrototypePush, DatePrototypeToISOString, ObjectEntries, RegExpPrototypeSymbolReplace, @@ -270,7 +269,7 @@ function jsToYaml(indent, name, value, seen) { ); if (processed.length > 0 && processed.length !== frame.length) { - ArrayPrototypePush(frames, processed); + frames[frames.length] = processed; } }, ); diff --git a/lib/internal/test_runner/runner.js b/lib/internal/test_runner/runner.js index b37198df6d76..6b23bafc6bb7 100644 --- a/lib/internal/test_runner/runner.js +++ b/lib/internal/test_runner/runner.js @@ -236,7 +236,7 @@ function getRunArgs(path, { forceExit, ArrayPrototypePushApply(runArgs, unknownProcessExecArgv); if (forceExit === true) { - ArrayPrototypePush(runArgs, '--test-force-exit'); + runArgs[runArgs.length] = '--test-force-exit'; } if (isUsingInspector()) { ArrayPrototypePush(runArgs, `--inspect-port=${getInspectPort(inspectPort)}`); @@ -251,32 +251,32 @@ function getRunArgs(path, { forceExit, ArrayPrototypeForEach(testTagFilterExpressions, (expr) => ArrayPrototypePush(runArgs, `--experimental-test-tag-filter=${expr}`)); } if (only === true) { - ArrayPrototypePush(runArgs, '--test-only'); + runArgs[runArgs.length] = '--test-only'; } if (forbidOnly != null && forbidOnly !== getOptionValue('--test-forbid-only')) { ArrayPrototypePush(runArgs, forbidOnly ? '--test-forbid-only' : '--no-test-forbid-only'); } if (timeout != null) { - ArrayPrototypePush(runArgs, `--test-timeout=${timeout}`); + runArgs[runArgs.length] = `--test-timeout=${timeout}`; } if (rerunFailuresFilePath) { - ArrayPrototypePush(runArgs, `--test-rerun-failures=${rerunFailuresFilePath}`); + runArgs[runArgs.length] = `--test-rerun-failures=${rerunFailuresFilePath}`; } if (randomize) { - ArrayPrototypePush(runArgs, '--test-randomize'); + runArgs[runArgs.length] = '--test-randomize'; } if (randomSeed != null) { - ArrayPrototypePush(runArgs, `--test-random-seed=${randomSeed}`); + runArgs[runArgs.length] = `--test-random-seed=${randomSeed}`; } ArrayPrototypePushApply(runArgs, execArgv); if (path === kIsolatedProcessName) { - ArrayPrototypePush(runArgs, '--test'); - ArrayPrototypePush(runArgs, '--test-isolation=none'); + runArgs[runArgs.length] = '--test'; + runArgs[runArgs.length] = '--test-isolation=none'; ArrayPrototypePushApply(runArgs, hasFiles ? testFiles : globPatterns ?? []); } else { - ArrayPrototypePush(runArgs, path); + runArgs[runArgs.length] = path; } ArrayPrototypePushApply(runArgs, suppliedArgs); @@ -383,7 +383,7 @@ class FileTest extends Test { } this.#accumulateReportItem(item); if (!this.isClearToSend()) { - ArrayPrototypePush(this.#reportBuffer, item); + this.#reportBuffer[this.#reportBuffer.length] = item; return; } this.#drainReportBuffer(); @@ -424,7 +424,7 @@ class FileTest extends Test { if (this.#rawBuffer[0] && TypedArrayPrototypeGetLength(this.#rawBuffer[0]) < kSerializedSizeHeader) { this.#rawBuffer[0] = Buffer.concat([this.#rawBuffer[0], readData]); } else { - ArrayPrototypePush(this.#rawBuffer, readData); + this.#rawBuffer[this.#rawBuffer.length] = readData; } this.#rawBufferSize += dataLength; this.#processRawBuffer(); diff --git a/lib/internal/test_runner/tag_filter.js b/lib/internal/test_runner/tag_filter.js index 0151abf31cc7..c4de8cf6aec9 100644 --- a/lib/internal/test_runner/tag_filter.js +++ b/lib/internal/test_runner/tag_filter.js @@ -147,7 +147,7 @@ function validateAndCanonicalizeTagValues(tags, optName) { if (!seen.has(lower)) { seen.add(lower); - ArrayPrototypePush(result, lower); + result[result.length] = lower; } } @@ -182,7 +182,7 @@ function lex(expr, name) { if (ch === kCharAmpersand) { if (i + 1 < len && StringPrototypeCharCodeAt(expr, i + 1) === kCharAmpersand) { - ArrayPrototypePush(tokens, { __proto__: null, type: T_AND, pos: i }); + tokens[tokens.length] = { __proto__: null, type: T_AND, pos: i }; i += 2; } else { throw new ERR_INVALID_ARG_VALUE( @@ -195,7 +195,7 @@ function lex(expr, name) { if (ch === kCharPipe) { if (i + 1 < len && StringPrototypeCharCodeAt(expr, i + 1) === kCharPipe) { - ArrayPrototypePush(tokens, { __proto__: null, type: T_OR, pos: i }); + tokens[tokens.length] = { __proto__: null, type: T_OR, pos: i }; i += 2; } else { throw new ERR_INVALID_ARG_VALUE( @@ -207,19 +207,19 @@ function lex(expr, name) { } if (ch === kCharExclaim) { - ArrayPrototypePush(tokens, { __proto__: null, type: T_NOT, pos: i }); + tokens[tokens.length] = { __proto__: null, type: T_NOT, pos: i }; i++; continue; } if (ch === kCharLParen) { - ArrayPrototypePush(tokens, { __proto__: null, type: T_LPAREN, pos: i }); + tokens[tokens.length] = { __proto__: null, type: T_LPAREN, pos: i }; i++; continue; } if (ch === kCharRParen) { - ArrayPrototypePush(tokens, { __proto__: null, type: T_RPAREN, pos: i }); + tokens[tokens.length] = { __proto__: null, type: T_RPAREN, pos: i }; i++; continue; } @@ -232,17 +232,17 @@ function lex(expr, name) { const lower = StringPrototypeToLowerCase(ident); if (lower === 'and') { - ArrayPrototypePush(tokens, { __proto__: null, type: T_AND, pos: start }); + tokens[tokens.length] = { __proto__: null, type: T_AND, pos: start }; } else if (lower === 'or') { - ArrayPrototypePush(tokens, { __proto__: null, type: T_OR, pos: start }); + tokens[tokens.length] = { __proto__: null, type: T_OR, pos: start }; } else if (lower === 'not') { - ArrayPrototypePush(tokens, { __proto__: null, type: T_NOT, pos: start }); + tokens[tokens.length] = { __proto__: null, type: T_NOT, pos: start }; } else { ArrayPrototypePush(tokens, { __proto__: null, type: T_IDENT, value: ident, pos: start }); } } - ArrayPrototypePush(tokens, { __proto__: null, type: T_EOF, pos: len }); + tokens[tokens.length] = { __proto__: null, type: T_EOF, pos: len }; return tokens; } diff --git a/lib/internal/test_runner/tests_stream.js b/lib/internal/test_runner/tests_stream.js index f8dd21152eeb..dc4402f0cba7 100644 --- a/lib/internal/test_runner/tests_stream.js +++ b/lib/internal/test_runner/tests_stream.js @@ -1,6 +1,5 @@ 'use strict'; const { - ArrayPrototypePush, ArrayPrototypeShift, ArrayPrototypeSlice, NumberMAX_SAFE_INTEGER, @@ -205,7 +204,7 @@ class TestsStream extends Readable { if (this.#canPush) { this.#canPush = this.push(message); } else { - ArrayPrototypePush(this.#buffer, message); + this.#buffer[this.#buffer.length] = message; } return this.#canPush; diff --git a/lib/internal/test_runner/utils.js b/lib/internal/test_runner/utils.js index 4f3728fe0926..01dfaf5e9546 100644 --- a/lib/internal/test_runner/utils.js +++ b/lib/internal/test_runner/utils.js @@ -290,11 +290,11 @@ function parseCommandLine() { reporters = getOptionValue('--test-reporter'); globalSetupPath = getOptionValue('--test-global-setup'); if (reporters.length === 0 && destinations.length === 0) { - ArrayPrototypePush(reporters, kDefaultReporter); + reporters[reporters.length] = kDefaultReporter; } if (reporters.length === 1 && destinations.length === 0) { - ArrayPrototypePush(destinations, kDefaultDestination); + destinations[destinations.length] = kDefaultDestination; } if (destinations.length !== reporters.length) { diff --git a/lib/internal/util/parse_args/parse_args.js b/lib/internal/util/parse_args/parse_args.js index e8751c6e2225..8c6af7f51ac5 100644 --- a/lib/internal/util/parse_args/parse_args.js +++ b/lib/internal/util/parse_args/parse_args.js @@ -201,7 +201,7 @@ function argsToTokens(args, options) { // Guideline 10 in https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html if (arg === '--') { // Everything after a bare '--' is considered a positional argument. - ArrayPrototypePush(tokens, { kind: 'option-terminator', index }); + tokens[tokens.length] = { kind: 'option-terminator', index }; ArrayPrototypePushApply( tokens, ArrayPrototypeMap(remainingArgs, (arg) => { return { kind: 'positional', index: ++index, value: arg }; @@ -239,7 +239,7 @@ function argsToTokens(args, options) { if (optionsGetOwn(options, longOption, 'type') !== 'string' || index === arg.length - 1) { // Boolean option, or last short in group. Well formed. - ArrayPrototypePush(expanded, `-${shortOption}`); + expanded[expanded.length] = `-${shortOption}`; } else { // String option in middle. Yuck. // Expand -abfFILE to -a -b -fFILE @@ -295,7 +295,7 @@ function argsToTokens(args, options) { continue; } - ArrayPrototypePush(tokens, { kind: 'positional', index, value: arg }); + tokens[tokens.length] = { kind: 'positional', index, value: arg }; } return tokens; } @@ -382,7 +382,7 @@ const parseArgs = (config = kEmptyObject) => { if (!allowPositionals) { throw new ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL(token.value); } - ArrayPrototypePush(result.positionals, token.value); + result.positionals[result.positionals.length] = token.value; } }); diff --git a/lib/internal/vfs/providers/memory.js b/lib/internal/vfs/providers/memory.js index 668ac9c8e837..e9b22f6843a5 100644 --- a/lib/internal/vfs/providers/memory.js +++ b/lib/internal/vfs/providers/memory.js @@ -626,7 +626,7 @@ class MemoryProvider extends VirtualProvider { } ArrayPrototypePush(results, new Dirent(childRelative, type, dirPath)); } else { - ArrayPrototypePush(results, childRelative); + results[results.length] = childRelative; } // Follow symlinks to directories for recursive traversal, skipping any diff --git a/lib/internal/vfs/providers/sea.js b/lib/internal/vfs/providers/sea.js index fa8df1b8f799..7d5560e17de7 100644 --- a/lib/internal/vfs/providers/sea.js +++ b/lib/internal/vfs/providers/sea.js @@ -327,7 +327,7 @@ class SEAProvider extends VirtualProvider { ArrayPrototypePush(results, new Dirent(childRelative, type, dirPath)); } else { - ArrayPrototypePush(results, childRelative); + results[results.length] = childRelative; } if (isDir) { diff --git a/lib/internal/vfs/providers/ziparchive.js b/lib/internal/vfs/providers/ziparchive.js index 297d960a1f22..20605847af8b 100644 --- a/lib/internal/vfs/providers/ziparchive.js +++ b/lib/internal/vfs/providers/ziparchive.js @@ -482,7 +482,7 @@ class ZipProvider extends VirtualProvider { if (withFileTypes) { ArrayPrototypePush(result, new Dirent(childName, isDir ? UV_DIRENT_DIR : UV_DIRENT_FILE, name)); } else { - ArrayPrototypePush(result, childName); + result[result.length] = childName; } } return result; diff --git a/lib/internal/vfs/root.js b/lib/internal/vfs/root.js index 234506abd8d9..3e0fc616bd09 100644 --- a/lib/internal/vfs/root.js +++ b/lib/internal/vfs/root.js @@ -104,7 +104,7 @@ class ReservedRootProvider extends VirtualProvider { const layerIds = []; for (const layerId of this.#layers.keys()) { - ArrayPrototypePush(layerIds, layerId); + layerIds[layerIds.length] = layerId; } ArrayPrototypeSort(layerIds, (a, b) => a - b); @@ -125,9 +125,9 @@ class ReservedRootProvider extends VirtualProvider { for (let j = 0; j < entries.length; j++) { if (withFileTypes) { entries[j].name = prefix + entries[j].name; - ArrayPrototypePush(result, entries[j]); + result[result.length] = entries[j]; } else { - ArrayPrototypePush(result, prefix + entries[j]); + result[result.length] = prefix + entries[j]; } } } diff --git a/lib/internal/vfs/watcher.js b/lib/internal/vfs/watcher.js index 799b537ab951..f85db473836e 100644 --- a/lib/internal/vfs/watcher.js +++ b/lib/internal/vfs/watcher.js @@ -604,7 +604,7 @@ class VFSWatchAsyncIterable { const { resolve } = this.#pendingResolvers.shift(); resolve({ value: event, done: false }); } else if (this.#pendingEvents.length < kMaxPendingEvents) { - ArrayPrototypePush(this.#pendingEvents, event); + this.#pendingEvents[this.#pendingEvents.length] = event; } // Drop events when queue is full to prevent unbounded memory growth }); diff --git a/lib/internal/webidl.js b/lib/internal/webidl.js index 819b5af205b7..648879f8a50c 100644 --- a/lib/internal/webidl.js +++ b/lib/internal/webidl.js @@ -4,7 +4,6 @@ const { ArrayBufferIsView, ArrayBufferPrototypeGetResizable, ArrayIsArray, - ArrayPrototypePush, ArrayPrototypeToSorted, BigInt, DataViewPrototypeGetBuffer, @@ -869,7 +868,7 @@ function createSequenceConverter(converter) { makeOptions(options, sequenceElementContext(idlSequence.length, options)), ); // Step 3.4: store the value and advance i. - ArrayPrototypePush(idlSequence, idlValue); + idlSequence[idlSequence.length] = idlValue; } return idlSequence; }; diff --git a/lib/internal/webstreams/readablestream.js b/lib/internal/webstreams/readablestream.js index 3181355959b6..da594fb34541 100644 --- a/lib/internal/webstreams/readablestream.js +++ b/lib/internal/webstreams/readablestream.js @@ -3659,7 +3659,7 @@ function readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue( controller, desc)) { readableByteStreamControllerShiftPendingPullInto(controller); - ArrayPrototypePush(filledPullIntos, desc); + filledPullIntos[filledPullIntos.length] = desc; } } return filledPullIntos; diff --git a/lib/internal/webworker.js b/lib/internal/webworker.js index 1361b6daa6e3..6ad59fe21399 100644 --- a/lib/internal/webworker.js +++ b/lib/internal/webworker.js @@ -6,7 +6,6 @@ /* eslint-disable capitalized-comments */ const { - ArrayPrototypePush, FunctionPrototypeBind, ObjectDefineProperties, ObjectDefineProperty, @@ -547,7 +546,7 @@ class WorkerGlobalScope extends EventTarget { const blob = urlRecord.protocol === 'blob:' ? resolveObjectURL(urlRecord.href) : undefined; // "Append urlRecord to urlRecords." - ArrayPrototypePush(urlRecords, { url: urlRecord, blob }); + urlRecords[urlRecords.length] = { url: urlRecord, blob }; } // "For each urlRecord of urlRecords:" for (let i = 0; i < urlRecords.length; i++) { diff --git a/lib/internal/zip/buffer.js b/lib/internal/zip/buffer.js index 582d8ae799af..6625edeacb7d 100644 --- a/lib/internal/zip/buffer.js +++ b/lib/internal/zip/buffer.js @@ -5,7 +5,6 @@ // `toBuffer()`/`toBufferSync()`. const { - ArrayPrototypePush, FunctionPrototypeCall, Map, MapPrototypeClear, @@ -156,7 +155,7 @@ class ZipBuffer { // Defaulting to the raw #comment bytes (not the decoded string) // round-trips a non-UTF-8 archive comment unchanged. for await (const chunk of createZipArchive(this.values(), { comment: comment ?? this.#comment, baseOffset })) { - ArrayPrototypePush(chunks, chunk); + chunks[chunks.length] = chunk; } return Buffer.concat(chunks); } @@ -171,7 +170,7 @@ class ZipBuffer { const { comment, baseOffset } = normalizeArchiveOptions(options); const chunks = []; for (const chunk of createZipArchiveSync(this.values(), { comment: comment ?? this.#comment, baseOffset })) { - ArrayPrototypePush(chunks, chunk); + chunks[chunks.length] = chunk; } return Buffer.concat(chunks); } diff --git a/lib/internal/zip/extra-fields.js b/lib/internal/zip/extra-fields.js index 0816268411f1..f0805c5aa4bd 100644 --- a/lib/internal/zip/extra-fields.js +++ b/lib/internal/zip/extra-fields.js @@ -6,7 +6,6 @@ // extended-timestamp builder used on the write path. const { - ArrayPrototypePush, Date, Number, } = primordials; @@ -171,7 +170,7 @@ function stripZip64Extra(extra) { record.writeUInt16LE(id, 0); record.writeUInt16LE(body.length, 2); body.copy(record, 4); - ArrayPrototypePush(parts, record); + parts[parts.length] = record; total += record.length; }); if (parts.length === 0) return EMPTY_BUFFER; diff --git a/lib/internal/zip/file.js b/lib/internal/zip/file.js index bae71ed485d5..ddc6e3f3d50b 100644 --- a/lib/internal/zip/file.js +++ b/lib/internal/zip/file.js @@ -98,14 +98,14 @@ function buildCentralDirectoryChunks(records, centralDirectoryOffset, comment) { // entry whose local header advertises a data descriptor (bit 3) must // keep advertising it in the rebuilt central header; see [kFinalize]. const header = records[i].entry[kFinalize](records[i].localOffset, true); - ArrayPrototypePush(centralHeaders, header); + centralHeaders[centralHeaders.length] = header; centralDirectorySize += header.length; } const count = records.length; const chunks = []; for (let i = 0; i < centralHeaders.length; i++) ArrayPrototypePush(chunks, centralHeaders[i]); const trailer = buildArchiveTrailer(count, centralDirectorySize, centralDirectoryOffset, comment); - for (let i = 0; i < trailer.length; i++) ArrayPrototypePush(chunks, trailer[i]); + for (let i = 0; i < trailer.length; i++) chunks[chunks.length] = trailer[i]; return { centralHeaders, chunks }; } @@ -184,7 +184,7 @@ function checkMemberRange(members, fileName, offset, dataEnd, size) { throw new ERR_ZIP_INVALID_ARCHIVE( `entry ${JSONStringify(fileName)} data is out of bounds`); } - ArrayPrototypePush(members, { fileName, offset, dataEnd }); + members[members.length] = { fileName, offset, dataEnd }; } // Sorted by local-header start, reject any member whose data runs into the @@ -558,7 +558,7 @@ class ZipFile { entry: value.entry ?? new ZipEntry(value.central, null, null), localOffset: value.localOffset, }); - ArrayPrototypePush(names, name); + names[names.length] = name; } return { records, names }; } @@ -639,7 +639,7 @@ class ZipFile { } const chunks = []; for (const chunk of createZipArchiveSync(entries, { comment: comment ?? this.#comment })) { - ArrayPrototypePush(chunks, chunk); + chunks[chunks.length] = chunk; } return Buffer.concat(chunks); } diff --git a/lib/internal/zip/headers.js b/lib/internal/zip/headers.js index bf6f7901516a..2882eff69895 100644 --- a/lib/internal/zip/headers.js +++ b/lib/internal/zip/headers.js @@ -6,7 +6,6 @@ // which walks the central directory into an array of headers. const { - ArrayPrototypePush, MathMax, Number, } = primordials; @@ -604,7 +603,7 @@ function readCentralDirectory(buffer, count) { if (header.diskNumber !== 0) { throw new ERR_ZIP_UNSUPPORTED_FEATURE('multi-disk archives are not supported'); } - ArrayPrototypePush(result, header); + result[result.length] = header; pos += header.byteLength; } if (pos !== buffer.length) { diff --git a/lib/net.js b/lib/net.js index ae7cca8ed6e6..e67784fd779b 100644 --- a/lib/net.js +++ b/lib/net.js @@ -1682,7 +1682,7 @@ function internalConnectMultiple(context) { } const attempt = { handle, req, index: current, own, timedOut: false }; - ArrayPrototypePush(context.pending, attempt); + context.pending[context.pending.length] = attempt; if (context.current < context.addresses.length) { debug('connect/multiple: setting the attempt timeout to %d ms', context.timeout); context[kTimeout] = setTimeout(internalConnectMultipleTimeout, context.timeout, context, attempt); @@ -2057,10 +2057,10 @@ function lookupAndConnectMultiple( const toAttempt = []; for (let i = 0, l = MathMax(validAddresses[0].length, validAddresses[1].length); i < l; i++) { if (i in validAddresses[0]) { - ArrayPrototypePush(toAttempt, validAddresses[0][i]); + toAttempt[toAttempt.length] = validAddresses[0][i]; } if (i in validAddresses[1]) { - ArrayPrototypePush(toAttempt, validAddresses[1][i]); + toAttempt[toAttempt.length] = validAddresses[1][i]; } } diff --git a/lib/os.js b/lib/os.js index 5e53879bd6d5..605eba554fba 100644 --- a/lib/os.js +++ b/lib/os.js @@ -236,7 +236,7 @@ function networkInterfaces() { const existing = result[name]; if (existing !== undefined) - ArrayPrototypePush(existing, entry); + existing[existing.length] = entry; else result[name] = [entry]; } diff --git a/lib/repl.js b/lib/repl.js index 4c227a0c17da..1a67928e9d02 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -427,7 +427,7 @@ class REPLServer extends Interface { self.on('close', function emitExit() { if (paused) { - ArrayPrototypePush(pausedBuffer, ['close']); + pausedBuffer[pausedBuffer.length] = ['close']; return; } self.emit('exit'); @@ -524,7 +524,7 @@ class REPLServer extends Interface { processLine(cmd); return; } - ArrayPrototypePush(lineQueue, cmd); + lineQueue[lineQueue.length] = cmd; pump(); }); diff --git a/lib/tls.js b/lib/tls.js index 288d783721d9..39285ebc062c 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -24,8 +24,6 @@ const { Array, ArrayIsArray, - // eslint-disable-next-line no-restricted-syntax - ArrayPrototypePush, JSONParse, ObjectDefineProperty, ObjectFreeze, @@ -163,13 +161,13 @@ function cacheDefaultCACertificates() { if (!getOptionValue('--use-openssl-ca')) { const bundled = cacheBundledRootCertificates(); for (let i = 0; i < bundled.length; ++i) { - ArrayPrototypePush(defaultCACertificates, bundled[i]); + defaultCACertificates[defaultCACertificates.length] = bundled[i]; } if (getOptionValue('--use-system-ca')) { const system = cacheSystemCACertificates(); for (let i = 0; i < system.length; ++i) { - ArrayPrototypePush(defaultCACertificates, system[i]); + defaultCACertificates[defaultCACertificates.length] = system[i]; } } } @@ -178,7 +176,7 @@ function cacheDefaultCACertificates() { const extra = cacheExtraCACertificates(); for (let i = 0; i < extra.length; ++i) { - ArrayPrototypePush(defaultCACertificates, extra[i]); + defaultCACertificates[defaultCACertificates.length] = extra[i]; } } diff --git a/lib/util.js b/lib/util.js index 02e205c8e16c..4da1b81ed3da 100644 --- a/lib/util.js +++ b/lib/util.js @@ -24,7 +24,6 @@ const { ArrayIsArray, ArrayPrototypePop, - ArrayPrototypePush, Error, ErrorCaptureStackTrace, FunctionPrototypeBind, @@ -536,7 +535,7 @@ function mapCallSite(callSites) { for (let i = 0; i < callSites.length; ++i) { const callSite = callSites[i]; const found = reconstructCallSite(callSite); - ArrayPrototypePush(result, found ?? callSite); + result[result.length] = found ?? callSite; } return result; } diff --git a/lib/wasi.js b/lib/wasi.js index b81835dfede5..714ead1fd14d 100644 --- a/lib/wasi.js +++ b/lib/wasi.js @@ -67,7 +67,7 @@ class WASI { ObjectEntries(options.env), ({ 0: key, 1: value }) => { if (value !== undefined) - ArrayPrototypePush(env, `${key}=${value}`); + env[env.length] = `${key}=${value}`; }); }