Skip to content

Commit

Permalink
url: using util._extend for improving profermace
Browse files Browse the repository at this point in the history
`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.

Refs: nodejs/CTC#62
  • Loading branch information
starkwang committed Oct 8, 2017
1 parent 2da7d9b commit 12b4145
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class URLSearchParams {
return ctx.stylize('[Object]', 'special');

var separator = ', ';
var innerOpts = Object.assign({}, ctx);
var innerOpts = util._extend({}, ctx);
if (recurseTimes !== null) {
innerOpts.depth = recurseTimes - 1;
}
Expand Down Expand Up @@ -373,7 +373,7 @@ Object.defineProperties(URL.prototype, {
value: function format(options) {
if (options && typeof options !== 'object')
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'options', 'object');
options = Object.assign({
options = util._extend({
fragment: true,
unicode: false,
search: true,
Expand Down Expand Up @@ -1244,7 +1244,7 @@ defineIDLClass(URLSearchParamsIteratorPrototype, 'URLSearchParamsIterator', {
if (typeof recurseTimes === 'number' && recurseTimes < 0)
return ctx.stylize('[Object]', 'special');

const innerOpts = Object.assign({}, ctx);
const innerOpts = util._extend({}, ctx);
if (recurseTimes !== null) {
innerOpts.depth = recurseTimes - 1;
}
Expand Down

0 comments on commit 12b4145

Please sign in to comment.