From 27217675765f05f3d30203953030e1b7d72a6af1 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Thu, 28 Dec 2017 23:44:24 +0100 Subject: [PATCH] util: improve setting default options Object.assign is currently very slow. Using Object.keys is much faster in v8 6.3. --- lib/util.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/util.js b/lib/util.js index ad5285360a8d8f..64719d597d7dd7 100644 --- a/lib/util.js +++ b/lib/util.js @@ -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; } });