Skip to content

Commit

Permalink
util: improve setting default options
Browse files Browse the repository at this point in the history
Object.assign is currently very slow. Using Object.keys is much
faster in v8 6.3.
  • Loading branch information
BridgeAR committed Dec 30, 2017
1 parent 2d845cf commit 2721767
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ Object.defineProperty(inspect, 'defaultOptions', {
if (options === null || typeof options !== 'object') {
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'options', 'Object');
}
Object.assign(inspectDefaultOptions, options);
const keys = Object.keys(options);
for (var i = 0; i < keys.length; i++)
inspectDefaultOptions[keys[i]] = options[keys[i]];
return inspectDefaultOptions;
}
});
Expand Down

0 comments on commit 2721767

Please sign in to comment.