Skip to content

Commit 6ff397d

Browse files
starkwangtargos
authored andcommitted
url: using util._extend for improving profermace
`Object.assign` is much slower than `util._extend` according to the refs. This change is to convert the `Object.assign` to use `util._extend` in url module for improving profermance. PR-URL: #16081 Refs: nodejs/CTC#62 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
1 parent 8a151be commit 6ff397d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/internal/url.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class URLSearchParams {
170170
return ctx.stylize('[Object]', 'special');
171171

172172
var separator = ', ';
173-
var innerOpts = Object.assign({}, ctx);
173+
var innerOpts = util._extend({}, ctx);
174174
if (recurseTimes !== null) {
175175
innerOpts.depth = recurseTimes - 1;
176176
}
@@ -373,7 +373,7 @@ Object.defineProperties(URL.prototype, {
373373
value: function format(options) {
374374
if (options && typeof options !== 'object')
375375
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'options', 'object');
376-
options = Object.assign({
376+
options = util._extend({
377377
fragment: true,
378378
unicode: false,
379379
search: true,
@@ -1244,7 +1244,7 @@ defineIDLClass(URLSearchParamsIteratorPrototype, 'URLSearchParamsIterator', {
12441244
if (typeof recurseTimes === 'number' && recurseTimes < 0)
12451245
return ctx.stylize('[Object]', 'special');
12461246

1247-
const innerOpts = Object.assign({}, ctx);
1247+
const innerOpts = util._extend({}, ctx);
12481248
if (recurseTimes !== null) {
12491249
innerOpts.depth = recurseTimes - 1;
12501250
}

0 commit comments

Comments
 (0)