mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
lib: use <array>.push and <array>.unshift instead of <array>.concat
Using `push` and `unshift` methods is more performant than reassigning a new array created with `concat`. PR-URL: https://github.com/nodejs/node/pull/37239 Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
f392ac0bbe
commit
83cce8717f
|
|
@ -22,7 +22,7 @@
|
|||
'use strict';
|
||||
|
||||
const {
|
||||
ArrayPrototypeConcat,
|
||||
ArrayPrototypePushApply,
|
||||
MathMin,
|
||||
Symbol,
|
||||
RegExpPrototypeTest,
|
||||
|
|
@ -66,7 +66,7 @@ function parserOnHeaders(headers, url) {
|
|||
// Once we exceeded headers limit - stop collecting them
|
||||
if (this.maxHeaderPairs <= 0 ||
|
||||
this._headers.length < this.maxHeaderPairs) {
|
||||
this._headers = ArrayPrototypeConcat(this._headers, headers);
|
||||
ArrayPrototypePushApply(this._headers, headers);
|
||||
}
|
||||
this._url += url;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
// message port.
|
||||
|
||||
const {
|
||||
ArrayPrototypeConcat,
|
||||
ArrayPrototypeForEach,
|
||||
ArrayPrototypePushApply,
|
||||
ArrayPrototypeSplice,
|
||||
ObjectDefineProperty,
|
||||
PromisePrototypeCatch,
|
||||
|
|
@ -126,7 +126,7 @@ port.on('message', (message) => {
|
|||
loadPreloadModules();
|
||||
initializeFrozenIntrinsics();
|
||||
if (argv !== undefined) {
|
||||
process.argv = ArrayPrototypeConcat(process.argv, argv);
|
||||
ArrayPrototypePushApply(process.argv, argv);
|
||||
}
|
||||
publicWorker.parentPort = publicPort;
|
||||
publicWorker.workerData = workerData;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ const {
|
|||
ArrayPrototypeSlice,
|
||||
ArrayPrototypeSplice,
|
||||
ArrayPrototypeUnshift,
|
||||
ArrayPrototypeUnshiftApply,
|
||||
Boolean,
|
||||
Error,
|
||||
JSONParse,
|
||||
|
|
@ -1204,7 +1205,7 @@ Module._initPaths = function() {
|
|||
path.resolve(process.execPath, '..') :
|
||||
path.resolve(process.execPath, '..', '..');
|
||||
|
||||
let paths = [path.resolve(prefixDir, 'lib', 'node')];
|
||||
const paths = [path.resolve(prefixDir, 'lib', 'node')];
|
||||
|
||||
if (homeDir) {
|
||||
ArrayPrototypeUnshift(paths, path.resolve(homeDir, '.node_libraries'));
|
||||
|
|
@ -1212,10 +1213,10 @@ Module._initPaths = function() {
|
|||
}
|
||||
|
||||
if (nodePath) {
|
||||
paths = ArrayPrototypeConcat(ArrayPrototypeFilter(
|
||||
ArrayPrototypeUnshiftApply(paths, ArrayPrototypeFilter(
|
||||
StringPrototypeSplit(nodePath, path.delimiter),
|
||||
Boolean
|
||||
), paths);
|
||||
));
|
||||
}
|
||||
|
||||
modulePaths = paths;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user