Skip to content

Commit 6ff397d

Browse files
starkwangtargos
authored andcommittedOct 18, 2017
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 <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Brian White <[email protected]>
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

+3-3
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)
Please sign in to comment.